]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api.acr/src/org/argeo/api/acr/AttributeFormatter.java
1 package org
.argeo
.api
.acr
;
4 * An attribute type MUST consistently parse a string to an object so that
5 * <code>parse(obj.toString()).equals(obj)</code> is verified.
6 * {@link #format(Object)} can be overridden to provide more efficient
7 * implementations but the returned <code>String</code> MUST be the same, that
8 * is <code>format(obj).equals(obj.toString())</code> is verified.
10 public interface AttributeFormatter
<T
> {
11 /** Parses a String to a Java object. */
12 T
parse(String str
) throws IllegalArgumentException
;
14 /** Default implementation returns {@link Object#toString()} on the argument. */
15 default String
format(T obj
) {
16 return obj
.toString();