@Test public void copyDoesNotCloneImmutableInstances() throws Exception { ImmutableLanguage original = simpleLanguage(); ImmutableLanguage copy = ImmutableLanguage.copyOf(original); assertThat(copy,sameInstance(original)); }
static ImmutableLanguage copyOf(Language language) { ImmutableLanguage result=null; if(language instanceof ImmutableLanguage) { result=(ImmutableLanguage)language; } else if(language!=null) { result=new ImmutableLanguage(language.locale()); } return result; }
ImmutableLanguage implements Language { static ImmutableLanguage copyOf(Language language) { ImmutableLanguage result=null; if(language instanceof ImmutableLanguage) { result=(ImmutableLanguage)language; } else if(language!=null) { result=new ImmutableLanguage(language.locale()); } return result; } }
ImmutableLanguage implements Language { static ImmutableLanguage copyOf(Language language) { ImmutableLanguage result=null; if(language instanceof ImmutableLanguage) { result=(ImmutableLanguage)language; } else if(language!=null) { result=new ImmutableLanguage(language.locale()); } return result; } ImmutableLanguage(Locale locale); }
ImmutableLanguage implements Language { static ImmutableLanguage copyOf(Language language) { ImmutableLanguage result=null; if(language instanceof ImmutableLanguage) { result=(ImmutableLanguage)language; } else if(language!=null) { result=new ImmutableLanguage(language.locale()); } return result; } ImmutableLanguage(Locale locale); @Override boolean isWildcard(); @Override String primaryTag(); @Override String subTag(); @Override Locale locale(); @Override String toHeader(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
ImmutableLanguage implements Language { static ImmutableLanguage copyOf(Language language) { ImmutableLanguage result=null; if(language instanceof ImmutableLanguage) { result=(ImmutableLanguage)language; } else if(language!=null) { result=new ImmutableLanguage(language.locale()); } return result; } ImmutableLanguage(Locale locale); @Override boolean isWildcard(); @Override String primaryTag(); @Override String subTag(); @Override Locale locale(); @Override String toHeader(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }