The Catalog API provides an interface to give a common behavior to an Enum, such as searching for a specific Enum element based on the field value set in the Enum, or checking if a specific value is defined in the field of the Enum.
APACHE-2.0 License
Table of Contents
Make easier to maintain and use constants!
This is a Java-based API designed to make the constants group more maintainable and extensible.
It manages regularized constants as a single catalog
and provides a convenient utility interface to manipulate the catalog
.
Enum
public static final
constant classes anymoreNote: Replace version you want to use. Check the latest Packages. Please contact me for a token to download the package.
Maven
<dependency>
<groupId>org.thinkit.api.catalog</groupId>
<artifactId>catalog-api</artifactId>
<version>v1.0.3</version>
</dependency>
<servers>
<server>
<id>github</id>
<username>myConsciousness</username>
<password>xxxxxxxxxxxxxxxxxx</password>
</server>
</servers>
Gradle
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/myConsciousness/catalog-api")
credentials {
username = "myConsciousness"
password = "xxxxxxxxxxxxxxxxxx"
}
}
}
dependencies {
implementation 'org.thinkit.api.catalog:catalog-api:v1.0.3'
}
The Catalog API
currently provides the following interfaces.
Choose the interface you want to use depending on your needs.
Interface | Overview |
---|---|
Catalog<E extends Catalog> | This is the basic catalog interface.Elements of the concrete catalog class that implement this interface have a code value .You can use the common behavior defined in the Catalog interface. |
BiCatalog<E extends BiCatalog<E, T>, T> | Each element of a concrete catalog class that implements this interface can have a code value plus a value of any data type .The arbitrary data type is defined at the time of implementation of the concrete catalog class.You can use the common behavior of the interface. |
Catalog<E extends Catalog>
import org.thinkit.api.catalog.Catalog;
/**
* Because the catalog applies the mechanism of recursive generics,
* specify own type to the generics when implement the Catalog interface.
*/
public enum TestCatalog implements Catalog<TestCatalog> {
/**
* Catalog constants need unique code value as an parameter
*/
TEST(0);
/**
* Required code value
*/
private int code;
/**
* Simple constructor
*/
TestCatalog(int code) {
this.code = code;
}
@Override
public int getCode() {
return this.code;
}
}
BiCatalog<E extends BiCatalog<E, T>, T>
import org.thinkit.api.catalog.BiCatalog;
/**
* Because the catalog applies the mechanism of recursive generics,
* specify own type to the generics when implement the BiCatalog interface.
*/
public enum TestBiCatalog implements BiCatalog<TestBiCatalog, String> {
/**
* BiCatalog constants need unique code value and any tag value as parameters
*/
TEST(0, "test");
/**
* Required code value
*/
private int code;
/**
* Required tag value.
* The data type of the tag is the data type specified to generics when implement BiCatalog interface.
*/
private String tag;
/**
* Simple constructor
*/
TestCatalog(int code, String tag) {
this.code = code;
this.tag = tag;
}
@Override
public int getCode() {
return this.code;
}
@Override
public String getTag() {
return this.tag;
}
}
Copyright 2020 Kato Shinya.
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.
Catalog API
was designed and implemented by Kato Shinya, who works as a freelance developer.
Regardless of the means or content of communication, I would love to hear from you if you have any questions or concerns. I do not check my email box very often so a response may be delayed, anyway thank you for your interest!