Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-3993 Add default identifier bridges for Character, Byte, Bool…
…ean, Byte, Float, Double
- Loading branch information
Showing
6 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
.../org/hibernate/search/mapper/pojo/bridge/builtin/impl/DefaultBooleanIdentifierBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.bridge.builtin.impl; | ||
|
||
import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeFromDocumentIdentifierContext; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext; | ||
|
||
public final class DefaultBooleanIdentifierBridge implements IdentifierBridge<Boolean> { | ||
|
||
@Override | ||
public String toDocumentIdentifier(Boolean propertyValue, IdentifierBridgeToDocumentIdentifierContext context) { | ||
return propertyValue.toString(); | ||
} | ||
|
||
@Override | ||
public Boolean fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { | ||
return Boolean.parseBoolean( documentIdentifier ); | ||
} | ||
|
||
@Override | ||
public boolean isCompatibleWith(IdentifierBridge<?> other) { | ||
return getClass().equals( other.getClass() ); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...ava/org/hibernate/search/mapper/pojo/bridge/builtin/impl/DefaultByteIdentifierBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.bridge.builtin.impl; | ||
|
||
import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeFromDocumentIdentifierContext; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext; | ||
|
||
public final class DefaultByteIdentifierBridge implements IdentifierBridge<Byte> { | ||
|
||
@Override | ||
public String toDocumentIdentifier(Byte propertyValue, IdentifierBridgeToDocumentIdentifierContext context) { | ||
return propertyValue.toString(); | ||
} | ||
|
||
@Override | ||
public Byte fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { | ||
return Byte.parseByte( documentIdentifier ); | ||
} | ||
|
||
@Override | ||
public boolean isCompatibleWith(IdentifierBridge<?> other) { | ||
return getClass().equals( other.getClass() ); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...rg/hibernate/search/mapper/pojo/bridge/builtin/impl/DefaultCharacterIdentifierBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.bridge.builtin.impl; | ||
|
||
import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeFromDocumentIdentifierContext; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext; | ||
|
||
public final class DefaultCharacterIdentifierBridge implements IdentifierBridge<Character> { | ||
|
||
@Override | ||
public String toDocumentIdentifier(Character propertyValue, IdentifierBridgeToDocumentIdentifierContext context) { | ||
return propertyValue.toString(); | ||
} | ||
|
||
@Override | ||
public Character fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { | ||
return documentIdentifier.charAt( 0 ); | ||
} | ||
|
||
@Override | ||
public boolean isCompatibleWith(IdentifierBridge<?> other) { | ||
return getClass().equals( other.getClass() ); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...a/org/hibernate/search/mapper/pojo/bridge/builtin/impl/DefaultDoubleIdentifierBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.bridge.builtin.impl; | ||
|
||
import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeFromDocumentIdentifierContext; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext; | ||
|
||
public final class DefaultDoubleIdentifierBridge implements IdentifierBridge<Double> { | ||
|
||
@Override | ||
public String toDocumentIdentifier(Double propertyValue, IdentifierBridgeToDocumentIdentifierContext context) { | ||
return propertyValue.toString(); | ||
} | ||
|
||
@Override | ||
public Double fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { | ||
return Double.parseDouble( documentIdentifier ); | ||
} | ||
|
||
@Override | ||
public boolean isCompatibleWith(IdentifierBridge<?> other) { | ||
return getClass().equals( other.getClass() ); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...va/org/hibernate/search/mapper/pojo/bridge/builtin/impl/DefaultFloatIdentifierBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.bridge.builtin.impl; | ||
|
||
import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeFromDocumentIdentifierContext; | ||
import org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext; | ||
|
||
public final class DefaultFloatIdentifierBridge implements IdentifierBridge<Float> { | ||
|
||
@Override | ||
public String toDocumentIdentifier(Float propertyValue, IdentifierBridgeToDocumentIdentifierContext context) { | ||
return propertyValue.toString(); | ||
} | ||
|
||
@Override | ||
public Float fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { | ||
return Float.parseFloat( documentIdentifier ); | ||
} | ||
|
||
@Override | ||
public boolean isCompatibleWith(IdentifierBridge<?> other) { | ||
return getClass().equals( other.getClass() ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters