Subtag implements Serializable, Cloneable,
		Comparable<Subtag> { public Subtag canonicalize() { switch (type) { case REGION: Region region = getEnum(); return region.getPreferred().newSubtag(); case PRIMARY: Language language = getEnum(); return language.getPreferred().newSubtag(); case SCRIPT: Script script = getEnum(); return script.getPreferred().newSubtag(); case VARIANT: Variant variant = getEnum(); return variant.getPreferred().newSubtag(); case EXTLANG: Extlang extlang = getEnum(); return extlang.getPreferred().newSubtag(); case EXTENSION: case GRANDFATHERED: case PRIVATEUSE: case SINGLETON: default: return this; } } Subtag(Language language);  Subtag(Script script);  Subtag(Region region);  Subtag(Variant variant);  Subtag(Extlang extlang);  Subtag(Singleton singleton);  Subtag(Type type, String name);   Subtag();  Subtag(Type type, String name, Subtag prev);   Subtag(Type type, String name, Subtag prev, Subtag next); Type getType(); String getName(); Subtag getPrevious(); Subtag getNext(); String toString(); int hashCode(); boolean equals(Object obj); Subtag clone(); boolean isDeprecated(); @SuppressWarnings("unchecked") T getEnum(); boolean isValid(); Subtag canonicalize(); static Subtag newWildcard(); int compareTo(Subtag o);  }
@Test public void testCanonicalize() { Subtag region = new Subtag(Region.DE); Subtag lang = new Subtag(Language.IW); Subtag script = new Subtag(Script.LATN); Subtag variant = new Subtag(Variant.FONIPA); Subtag extension = new Subtag(Type.EXTENSION, "abc"); assertNotNull(region.canonicalize()); assertNotNull(lang.canonicalize()); assertNotNull(script.canonicalize()); assertNotNull(variant.canonicalize()); assertNotNull(extension.canonicalize()); }