org.immutables.ordinal.OrdinalValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ordinal Show documentation
Show all versions of ordinal Show documentation
API and support runtime classes for implementing immutable objects as
set enum-like object values, accumulated in so called "domains". This
allows for special performance optiomization, like using bit-sets to
efficiently calculate inclusion in set or set differences.
/*
Copyright 2013-2014 Immutables Authors and Contributors
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.
*/
package org.immutables.ordinal;
/**
* Objects implementing this interface has stable ordinal attribute that could be
* used to arrange these object among other elements of the same type. Instances of the same kind
* are expected to be {@link Object#equals(Object) equal} if they have the same value of
* {@link #ordinal()}.
*
* In essence, this type expresses enumeration for object types that cannot be represented as Java
* {@code enum}s. One of the justifications of such usage is sophisticated optimizations possible
* with data-structures that relies on the fact that number of different values of some type is
* countable and limited (usually, in correspondence to the problem domain that is being modeled).
* @see ImmutableOrdinalSet
* @param element type
*/
public interface OrdinalValue> {
/**
* Zero based ordinal value
* @return the ordinal value
*/
int ordinal();
/**
* Domain that contains family of objects, arranged by ordinal
* @return the domain
*/
OrdinalDomain domain();
}