001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.rng; 018 019/** 020 * Applies to generators whose internal state can be saved and restored. 021 * 022 * @since 1.0 023 */ 024public interface RestorableUniformRandomProvider extends UniformRandomProvider { 025 /** 026 * Saves the state of a generator. 027 * 028 * @return the current state of this instance. It is a value that can 029 * subsequently be passed to the {@link #restoreState(RandomProviderState) 030 * restore} method. 031 * @throws UnsupportedOperationException if the underlying source of 032 * randomness does not support this functionality. 033 */ 034 RandomProviderState saveState(); 035 036 /** 037 * Restores the state of a generator. 038 * 039 * @param state State which this instance will be set to. 040 * This parameter would usually have been obtained by a call to 041 * {@link #saveState() saveState} performed either on the same 042 * object as this one, or an object of the exact same class. 043 * @throws UnsupportedOperationException if the underlying source of 044 * randomness does not support this functionality. 045 * @throws IllegalArgumentException if it was detected that the 046 * {@code state} argument is incompatible with this intance. 047 */ 048 void restoreState(RandomProviderState state); 049}