View Javadoc
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    *      https://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  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  package org.hipparchus.random;
23  
24  /**
25   * A random generator which forwards all its method calls to another random generator.
26   * <p>
27   * Subclasses should override one or more methods to modify the behavior of the backing
28   * random generator as desired per the decorator pattern.
29   */
30  abstract class ForwardingRandomGenerator implements RandomGenerator {
31  
32      /**
33       * Returns the backing delegate instance that methods are forwarded to.
34       * <p>
35       * Concrete subclasses override this method to supply the instance being decorated.
36       *
37       * @return the delegate instance
38       */
39      protected abstract RandomGenerator delegate();
40  
41      /** {@inheritDoc} */
42      @Override
43      public void setSeed(int seed) {
44          delegate().setSeed(seed);
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public void setSeed(int[] seed) {
50          delegate().setSeed(seed);
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public void setSeed(long seed) {
56          delegate().setSeed(seed);
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      public void nextBytes(byte[] bytes) {
62          delegate().nextBytes(bytes);
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public void nextBytes(byte[] bytes, int offset, int length) {
68          delegate().nextBytes(bytes, offset, length);
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public int nextInt() {
74          return delegate().nextInt();
75      }
76  
77      /** {@inheritDoc} */
78      @Override
79      public int nextInt(int n) {
80          return delegate().nextInt(n);
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public long nextLong() {
86          return delegate().nextLong();
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public long nextLong(long n) {
92          return delegate().nextLong(n);
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public boolean nextBoolean() {
98          return delegate().nextBoolean();
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     public float nextFloat() {
104         return delegate().nextFloat();
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public double nextDouble() {
110         return delegate().nextDouble();
111     }
112 
113     /** {@inheritDoc} */
114     @Override
115     public double nextGaussian() {
116         return delegate().nextGaussian();
117     }
118 }