Here you can find the source of generateRandomBySampleSeed(long sampleSeed, long fallbackValue)
Parameter | Description |
---|---|
sampleSeed | sample seed to generate Random instance |
fallbackValue | sample seed fall back value |
public static Random generateRandomBySampleSeed(long sampleSeed, long fallbackValue)
//package com.java2s; /**/*w w w . j a va 2 s. c o m*/ * Copyright [2012-2014] PayPal Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.*; public class Main { /** * Generate random instance according to sample seed. * * @param sampleSeed * sample seed to generate Random instance * @param fallbackValue * sample seed fall back value * @return Random instance according to the sample seed value * If the sample seed value not equal to fallbackValue, then will use it to generate Random instance. * Else take fallback measure: generate Random instance without given seed. */ public static Random generateRandomBySampleSeed(long sampleSeed, long fallbackValue) { if (sampleSeed != fallbackValue) { return new Random(sampleSeed); } return new Random(); } }