@Test public void testNewInstance$invalid$names() throws Exception { try { EnumerationHelper.newInstance(Invalid$Names.Missing.class); fail("Class should fail: "+Invalid$Names.Missing.class); } catch (InvalidDefinitionException e) { } try { EnumerationHelper.newInstance(Invalid$Names.WrongReturn$NoParameterizedType.class); fail("Class should fail: "+Invalid$Names.WrongReturn$NoParameterizedType.class); } catch (InvalidDefinitionException e) { } try { EnumerationHelper.newInstance(Invalid$Names.WrongReturn$NoSet.class); fail("Class should fail: "+Invalid$Names.WrongReturn$NoSet.class); } catch (InvalidDefinitionException e) { } try { EnumerationHelper.newInstance(Invalid$Names.WrongReturn$NoString.class); fail("Class should fail: "+Invalid$Names.WrongReturn$NoString.class); } catch (InvalidDefinitionException e) { } }
static <S> EnumerationHelper<S> newInstance(Class<? extends S> clazz) { List<String> violations=new ArrayList<String>(); Set<String> names = getNames(clazz,violations); Method toName=getNameMethod(clazz,violations); Method fromName=getFromURIMethod(clazz,violations); if(!violations.isEmpty()) { throw new InvalidDefinitionException("Violations found: "+violations); } return new EnumerationHelper<S>(names, clazz,toName,fromName); }
EnumerationHelper { static <S> EnumerationHelper<S> newInstance(Class<? extends S> clazz) { List<String> violations=new ArrayList<String>(); Set<String> names = getNames(clazz,violations); Method toName=getNameMethod(clazz,violations); Method fromName=getFromURIMethod(clazz,violations); if(!violations.isEmpty()) { throw new InvalidDefinitionException("Violations found: "+violations); } return new EnumerationHelper<S>(names, clazz,toName,fromName); } }
EnumerationHelper { static <S> EnumerationHelper<S> newInstance(Class<? extends S> clazz) { List<String> violations=new ArrayList<String>(); Set<String> names = getNames(clazz,violations); Method toName=getNameMethod(clazz,violations); Method fromName=getFromURIMethod(clazz,violations); if(!violations.isEmpty()) { throw new InvalidDefinitionException("Violations found: "+violations); } return new EnumerationHelper<S>(names, clazz,toName,fromName); } private  EnumerationHelper(Set<String> names, Class<? extends S> clazz, Method name, Method valueOf); }
EnumerationHelper { static <S> EnumerationHelper<S> newInstance(Class<? extends S> clazz) { List<String> violations=new ArrayList<String>(); Set<String> names = getNames(clazz,violations); Method toName=getNameMethod(clazz,violations); Method fromName=getFromURIMethod(clazz,violations); if(!violations.isEmpty()) { throw new InvalidDefinitionException("Violations found: "+violations); } return new EnumerationHelper<S>(names, clazz,toName,fromName); } private  EnumerationHelper(Set<String> names, Class<? extends S> clazz, Method name, Method valueOf);  }
EnumerationHelper { static <S> EnumerationHelper<S> newInstance(Class<? extends S> clazz) { List<String> violations=new ArrayList<String>(); Set<String> names = getNames(clazz,violations); Method toName=getNameMethod(clazz,violations); Method fromName=getFromURIMethod(clazz,violations); if(!violations.isEmpty()) { throw new InvalidDefinitionException("Violations found: "+violations); } return new EnumerationHelper<S>(names, clazz,toName,fromName); } private  EnumerationHelper(Set<String> names, Class<? extends S> clazz, Method name, Method valueOf);   }