= LogicalType
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

A generalization of Java's class type to also hold a logical name, which can be supplied lazily.

Equality is driven by the corresponding class exclusively, meaning the logical name is ignored in order to not cause any side-effects on logical name memoization eg. it happening too early.

Meta-model validators will take care, that there is no logical name ambiguity: There cannot be any LogicalTypes sharing the same corresponding class while having different logical names.

== API

[source,java]
.LogicalType.java
----
class LogicalType {
  LogicalType lazy(Class<?> correspondingClass, Supplier<String> logicalNameProvider)     // <.>
  LogicalType eager(Class<?> correspondingClass, String logicalName)     // <.>
  LogicalType fqcn(Class<?> correspondingClass)     // <.>
  LogicalType infer(Class<?> correspondingClass)     // <.>
  String getClassName()     // <.>
  String getLogicalTypeName()     // <.>
  String getLogicalTypeSimpleName()     // <.>
  String getNamespace()     // <.>
  String getLogicalTypeNameFormatted(String root, String delimiter)     // <.>
  boolean equals(Object obj)
  boolean isEqualTo(LogicalType other)
  int hashCode()
  int compareTo(LogicalType other)
}
----

<.> xref:#lazy_Class_Supplier[lazy(Class, Supplier)]
+
--
Returns a new xref:refguide:applib:index/id/LogicalType.adoc[LogicalType] based on the corresponding class and a _logicalNameProvider_ for lazy logical name lookup.
--
<.> xref:#eager_Class_String[eager(Class, String)]
+
--
Returns a new TypeIdentifier based on the corresponding class and (ahead of time) known _logicalName_ .
--
<.> xref:#fqcn_Class[fqcn(Class)]
+
--
Use the corresponding class's fully qualified name for the _logicalName_ . Most likely used in testing scenarios.
--
<.> xref:#infer_Class[infer(Class)]
+
--
Infer from annotations.
--
<.> xref:#getClassName_[getClassName()]
+
--
Canonical name of the corresponding class.
--
<.> xref:#getLogicalTypeName_[getLogicalTypeName()]
+
--
Returns the logical-type-name (unique amongst non-abstract classes), as per the _LogicalTypeFacet_ .
--
<.> xref:#getLogicalTypeSimpleName_[getLogicalTypeSimpleName()]
+
--
The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ .
--
<.> xref:#getNamespace_[getNamespace()]
+
--
The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ .
--
<.> xref:#getLogicalTypeNameFormatted_String_String[getLogicalTypeNameFormatted(String, String)]
+
--
The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ . Returns a concatenation of _namespace_ , _delimiter_ and the _logical simple name_ , whereas in the absence of a _namespace_ returns a concatenation of _root_ and the _logical simple name_ .
--

== Members

[#lazy_Class_Supplier]
=== lazy(Class, Supplier)

Returns a new xref:refguide:applib:index/id/LogicalType.adoc[LogicalType] based on the corresponding class and a _logicalNameProvider_ for lazy logical name lookup.

[#eager_Class_String]
=== eager(Class, String)

Returns a new TypeIdentifier based on the corresponding class and (ahead of time) known _logicalName_ .

[#fqcn_Class]
=== fqcn(Class)

Use the corresponding class's fully qualified name for the _logicalName_ . Most likely used in testing scenarios.

[#infer_Class]
=== infer(Class)

Infer from annotations.

[#getClassName_]
=== getClassName()

Canonical name of the corresponding class.

[#getLogicalTypeName_]
=== getLogicalTypeName()

Returns the logical-type-name (unique amongst non-abstract classes), as per the _LogicalTypeFacet_ .

This will typically be the value of the _Named#value()_ annotation attribute. If none has been specified then will default to the fully qualified class name (with _ClassSubstitutorRegistry class name substituted_ if necessary to allow for runtime bytecode enhancement.

The _ObjectSpecification_ can be retrieved using _SpecificationLoader#specForLogicalTypeName(String)_ } passing the logical-type-name as argument.

[#getLogicalTypeSimpleName_]
=== getLogicalTypeSimpleName()

The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ .

Returns the _logical simple name_ part.

[#getNamespace_]
=== getNamespace()

The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ .

Returns the _namespace_ part.

[#getLogicalTypeNameFormatted_String_String]
=== getLogicalTypeNameFormatted(String, String)

The logical type name consists of 2 parts, the _namespace_ and the _logical simple name_ . Returns a concatenation of _namespace_ , _delimiter_ and the _logical simple name_ , whereas in the absence of a _namespace_ returns a concatenation of _root_ and the _logical simple name_ .
