@Test public void testMatches() { TypeDescriptor source = TypeDescriptor.valueOf(String[].class); TypeDescriptor target = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(UserAuthority.class)); assertFalse(new StringArrayToListOfTagsConverter().matches(source, target)); source = TypeDescriptor.valueOf(String.class); target = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Tag.class)); assertFalse(new StringArrayToListOfTagsConverter().matches(source, target)); source = TypeDescriptor.valueOf(String[].class); target = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Tag.class)); assertTrue(new StringArrayToListOfTagsConverter().matches(source, target)); }
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { boolean sourceValid = false, targetValid = false; if(sourceType.isArray()) { TypeDescriptor sourceTypeDesc = sourceType.getElementTypeDescriptor(); if(sourceTypeDesc != null) { if(String.class.isAssignableFrom(sourceTypeDesc.getObjectType())) { sourceValid = true; } } } if(targetType.isCollection()) { TypeDescriptor targetTypeDesc = targetType.getElementTypeDescriptor(); if(targetTypeDesc != null) { if(Tag.class.isAssignableFrom(targetTypeDesc.getObjectType())) { targetValid = true; } } } return sourceValid && targetValid; }
StringArrayToListOfTagsConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { boolean sourceValid = false, targetValid = false; if(sourceType.isArray()) { TypeDescriptor sourceTypeDesc = sourceType.getElementTypeDescriptor(); if(sourceTypeDesc != null) { if(String.class.isAssignableFrom(sourceTypeDesc.getObjectType())) { sourceValid = true; } } } if(targetType.isCollection()) { TypeDescriptor targetTypeDesc = targetType.getElementTypeDescriptor(); if(targetTypeDesc != null) { if(Tag.class.isAssignableFrom(targetTypeDesc.getObjectType())) { targetValid = true; } } } return sourceValid && targetValid; } }
StringArrayToListOfTagsConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { boolean sourceValid = false, targetValid = false; if(sourceType.isArray()) { TypeDescriptor sourceTypeDesc = sourceType.getElementTypeDescriptor(); if(sourceTypeDesc != null) { if(String.class.isAssignableFrom(sourceTypeDesc.getObjectType())) { sourceValid = true; } } } if(targetType.isCollection()) { TypeDescriptor targetTypeDesc = targetType.getElementTypeDescriptor(); if(targetTypeDesc != null) { if(Tag.class.isAssignableFrom(targetTypeDesc.getObjectType())) { targetValid = true; } } } return sourceValid && targetValid; }  }
StringArrayToListOfTagsConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { boolean sourceValid = false, targetValid = false; if(sourceType.isArray()) { TypeDescriptor sourceTypeDesc = sourceType.getElementTypeDescriptor(); if(sourceTypeDesc != null) { if(String.class.isAssignableFrom(sourceTypeDesc.getObjectType())) { sourceValid = true; } } } if(targetType.isCollection()) { TypeDescriptor targetTypeDesc = targetType.getElementTypeDescriptor(); if(targetTypeDesc != null) { if(Tag.class.isAssignableFrom(targetTypeDesc.getObjectType())) { targetValid = true; } } } return sourceValid && targetValid; }  @Override Set<ConvertiblePair> getConvertibleTypes(); @Override Object convert(Object source, TypeDescriptor sourceType,
			TypeDescriptor targetType); @Override boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType); }
StringArrayToListOfTagsConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { boolean sourceValid = false, targetValid = false; if(sourceType.isArray()) { TypeDescriptor sourceTypeDesc = sourceType.getElementTypeDescriptor(); if(sourceTypeDesc != null) { if(String.class.isAssignableFrom(sourceTypeDesc.getObjectType())) { sourceValid = true; } } } if(targetType.isCollection()) { TypeDescriptor targetTypeDesc = targetType.getElementTypeDescriptor(); if(targetTypeDesc != null) { if(Tag.class.isAssignableFrom(targetTypeDesc.getObjectType())) { targetValid = true; } } } return sourceValid && targetValid; }  @Override Set<ConvertiblePair> getConvertibleTypes(); @Override Object convert(Object source, TypeDescriptor sourceType,
			TypeDescriptor targetType); @Override boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType);  }