Package com.s24.gs1
Class GtinNormalizer
- java.lang.Object
-
- com.s24.gs1.GtinNormalizer
-
public class GtinNormalizer extends Object
Removes non-digit characters from a GTIN and adds leading zeros to GTINs according to the specified target length.To have unified GTIN values, you can use this normalizer. It precedes a GTIN with zeros. Due to the checksum calculation mechanism this won't affect the validity of a GTIN. Any non-digit characters will be removed.
-
-
Constructor Summary
Constructors Constructor Description GtinNormalizer(int targetLength)Creates a new GTIN normalizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringnormalize(CharSequence gtin)Adds leading zeros to a GTIN value.
-
-
-
Constructor Detail
-
GtinNormalizer
public GtinNormalizer(int targetLength)
Creates a new GTIN normalizer.- Parameters:
targetLength- A valid GTIN length to normalize GTINs- Throws:
IllegalArgumentException- If the target length is not a allowed GTIN format length
-
-
Method Detail
-
normalize
public String normalize(CharSequence gtin)
Adds leading zeros to a GTIN value.- Parameters:
gtin- The GTIN to normalize. Must not benullor empty.- Returns:
- The GTIN padded to the given target length and
- Throws:
IllegalArgumentException- If the input wasnullor empty
-
-