1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.math3.geometry.euclidean.threed;
19
20 import java.io.Serializable;
21
22 import org.apache.commons.math3.geometry.Space;
23 import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
24
25 /**
26 * This class implements a three-dimensional space.
27 * @version $Id: Euclidean3D.java 1416643 2012-12-03 19:37:14Z tn $
28 * @since 3.0
29 */
30 public class Euclidean3D implements Serializable, Space {
31
32 /** Serializable version identifier. */
33 private static final long serialVersionUID = 6249091865814886817L;
34
35 /** Private constructor for the singleton.
36 */
37 private Euclidean3D() {
38 }
39
40 /** Get the unique instance.
41 * @return the unique instance
42 */
43 public static Euclidean3D getInstance() {
44 return LazyHolder.INSTANCE;
45 }
46
47 /** {@inheritDoc} */
48 public int getDimension() {
49 return 3;
50 }
51
52 /** {@inheritDoc} */
53 public Euclidean2D getSubSpace() {
54 return Euclidean2D.getInstance();
55 }
56
57 // CHECKSTYLE: stop HideUtilityClassConstructor
58 /** Holder for the instance.
59 * <p>We use here the Initialization On Demand Holder Idiom.</p>
60 */
61 private static class LazyHolder {
62 /** Cached field instance. */
63 private static final Euclidean3D INSTANCE = new Euclidean3D();
64 }
65 // CHECKSTYLE: resume HideUtilityClassConstructor
66
67 /** Handle deserialization of the singleton.
68 * @return the singleton instance
69 */
70 private Object readResolve() {
71 // return the singleton instance
72 return LazyHolder.INSTANCE;
73 }
74
75 }