AbstractLongIdentifierGenerator.java

  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.  * Modificato da Link.it (https://link.it) per supportare le seguenti funzionalità:
  19.  * - Generazione ID all'interno delle interfacce di OpenSPCoop2
  20.  * - Gestione caratteri massimi per numeri e cifre
  21.  * - Possibilità di utilizzare lowerCase e/o upperCase
  22.  *
  23.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  24.  */
  25. package org.openspcoop2.utils.id.apache;

  26. import org.openspcoop2.utils.id.apache.serial.MaxReachedException;

  27. /**
  28.  * Abstract superclass for LongIdentifierGenerator implementations.
  29.  *
  30.  * Author of the original commons apache code:
  31.  * @author Commons-Id team
  32.  * @version $Id$
  33.  *
  34.  * Authors of the Link.it modification to the code:
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  */
  38. public abstract class AbstractLongIdentifierGenerator implements LongIdentifierGenerator {

  39.     /**
  40.      * Constructor.
  41.      */
  42.     protected AbstractLongIdentifierGenerator() {
  43.         super();
  44.     }

  45.     /**
  46.      * Returns the maximum value of an identifier from this generator.
  47.      *
  48.      * <p>The default implementation returns Long.MAX_VALUE. Implementations
  49.      * whose identifiers are bounded below Long.MAX_VALUE should override this method to
  50.      * return the maximum value of a generated identifier.</p>
  51.      *
  52.      * @return {@inheritDoc}
  53.      */
  54.     @Override
  55.     public long maxValue() {
  56.         return Long.MAX_VALUE;
  57.     }

  58.     /**
  59.      * Returns the minimum value of an identifier from this generator.
  60.      *
  61.      * <p>The default implementation returns Long.MIN_VALUE. Implementations
  62.      * whose identifiers are bounded above Long.MIN_VALUE should override this method to
  63.      * return the minimum value of a generated identifier.</p>
  64.      *
  65.      * @return {@inheritDoc}
  66.      */
  67.     @Override
  68.     public long minValue() {
  69.         return Long.MIN_VALUE;
  70.     }

  71.     @Override
  72.     public Object nextIdentifier() throws MaxReachedException {
  73.         return this.nextLongIdentifier();
  74.     }

  75.     @Override
  76.     public abstract Long nextLongIdentifier() throws MaxReachedException;
  77. }