@Test public void doesNotCloneNull() throws Exception { ImmutableVariant original = null; ImmutableVariant copy = ImmutableVariant.copyOf(original); assertThat(copy,sameInstance(original)); }
static ImmutableVariant copyOf(Variant other) { ImmutableVariant result=null; if(other instanceof ImmutableVariant) { result=(ImmutableVariant)other; } else if(other!=null) { result= new ImmutableVariant( ImmutableMediaType.copyOf(other.type()), ImmutableCharacterEncoding.copyOf(other.charset()), ImmutableLanguage.copyOf(other.language()) ); } return result; }
ImmutableVariant implements Variant { static ImmutableVariant copyOf(Variant other) { ImmutableVariant result=null; if(other instanceof ImmutableVariant) { result=(ImmutableVariant)other; } else if(other!=null) { result= new ImmutableVariant( ImmutableMediaType.copyOf(other.type()), ImmutableCharacterEncoding.copyOf(other.charset()), ImmutableLanguage.copyOf(other.language()) ); } return result; } }
ImmutableVariant implements Variant { static ImmutableVariant copyOf(Variant other) { ImmutableVariant result=null; if(other instanceof ImmutableVariant) { result=(ImmutableVariant)other; } else if(other!=null) { result= new ImmutableVariant( ImmutableMediaType.copyOf(other.type()), ImmutableCharacterEncoding.copyOf(other.charset()), ImmutableLanguage.copyOf(other.language()) ); } return result; } private  ImmutableVariant(ImmutableMediaType mediaType, ImmutableCharacterEncoding characterEncoding, ImmutableLanguage language); }
ImmutableVariant implements Variant { static ImmutableVariant copyOf(Variant other) { ImmutableVariant result=null; if(other instanceof ImmutableVariant) { result=(ImmutableVariant)other; } else if(other!=null) { result= new ImmutableVariant( ImmutableMediaType.copyOf(other.type()), ImmutableCharacterEncoding.copyOf(other.charset()), ImmutableLanguage.copyOf(other.language()) ); } return result; } private  ImmutableVariant(ImmutableMediaType mediaType, ImmutableCharacterEncoding characterEncoding, ImmutableLanguage language); @Override ImmutableMediaType type(); @Override ImmutableCharacterEncoding charset(); @Override ImmutableLanguage language(); @Override String toString(); }
ImmutableVariant implements Variant { static ImmutableVariant copyOf(Variant other) { ImmutableVariant result=null; if(other instanceof ImmutableVariant) { result=(ImmutableVariant)other; } else if(other!=null) { result= new ImmutableVariant( ImmutableMediaType.copyOf(other.type()), ImmutableCharacterEncoding.copyOf(other.charset()), ImmutableLanguage.copyOf(other.language()) ); } return result; } private  ImmutableVariant(ImmutableMediaType mediaType, ImmutableCharacterEncoding characterEncoding, ImmutableLanguage language); @Override ImmutableMediaType type(); @Override ImmutableCharacterEncoding charset(); @Override ImmutableLanguage language(); @Override String toString();  }