propertyValue=tmp; if (propertyValue != null && InetAddressInfo.isInetAddressRelated(methods[j])) { Object converted = null ; try { + protocolName + " with default value " + propertyValue + ".Exception is " +e, e); InetAddressInfo inetinfo = new InetAddressInfo(protocol, methods[j], properties, propertyValue, converted) ; && InetAddressInfo.isInetAddressRelated(fields[j])) { Object converted = null ; try { + protocolName + " with default value " + propertyValue + ".Exception is " +e, e); InetAddressInfo inetinfo = new InetAddressInfo(protocol, fields[j], properties, propertyValue, converted) ;
public String toString() { StringBuilder sb = new StringBuilder() ; sb.append("InetAddressInfo(") .append("protocol=" + protocol.getName()) .append(", propertyName=" + getPropertyName()) .append(", string value=" + getStringValue()) .append(", parameterized=" + isParameterized()); if (isParameterized()) sb.append(", baseType=" + getBaseType()) ; sb.append(")") ; return sb.toString(); } }
public List<InetAddress> getInetAddresses() { List<InetAddress> addresses = new ArrayList<>() ; if (getConvertedValue() == null) return addresses ; // if we take only an InetAddress argument if (!isParameterized()) { addresses.add(getInetAddress(getConvertedValue())) ; return addresses ; } // if we take a List<InetAddress> or similar else { List<?> values = (List<?>) getConvertedValue() ; if (values.isEmpty()) return addresses ; for (int i = 0; i < values.size(); i++) { addresses.add(getInetAddress(values.get(i))) ; } return addresses ; } }
propertyValue=tmp; if (propertyValue != null && InetAddressInfo.isInetAddressRelated(methods[j])) { Object converted = null ; try { + protocolName + " with default value " + propertyValue + ".Exception is " +e, e); InetAddressInfo inetinfo = new InetAddressInfo(protocol, methods[j], properties, propertyValue, converted) ; && InetAddressInfo.isInetAddressRelated(fields[j])) { Object converted = null ; try { + protocolName + " with default value " + propertyValue + ".Exception is " +e, e); InetAddressInfo inetinfo = new InetAddressInfo(protocol, fields[j], properties, propertyValue, converted) ;
if (isField()) propertyName=PropertyHelper.getPropertyName((Field)fieldOrMethod, properties) ; else if (isField()) this.isParameterized = hasParameterizedType((Field)fieldOrMethod) ; else this.isParameterized = hasParameterizedType((Method)fieldOrMethod) ; if (isField() && isParameterized) { else if (!isField() && isParameterized) {
/** * Returns all inet addresses found */ public static Collection<InetAddress> getAddresses(Map<String, Map<String, InetAddressInfo>> inetAddressMap) throws Exception { Set<InetAddress> addrs=new HashSet<>(); for(Map.Entry<String, Map<String, InetAddressInfo>> inetAddressMapEntry : inetAddressMap.entrySet()) { Map<String, InetAddressInfo> protocolInetAddressMap=inetAddressMapEntry.getValue(); for(Map.Entry<String, InetAddressInfo> protocolInetAddressMapEntry : protocolInetAddressMap.entrySet()) { InetAddressInfo inetAddressInfo=protocolInetAddressMapEntry.getValue(); // add InetAddressInfo to sets based on IP version List<InetAddress> addresses=inetAddressInfo.getInetAddresses(); for(InetAddress address : addresses) { if(address == null) throw new RuntimeException("failed converting address info to IP address: " + inetAddressInfo); addrs.add(address); } } } return addrs; }
static boolean isInetAddressRelated(Field f) { if (hasParameterizedType(f)) { // check for List<InetAddress>, List<InetSocketAddress>, List<IpAddress> ParameterizedType fieldtype = (ParameterizedType) f.getGenericType() ; // check that this parameterized type satisfies our constraints try { parameterizedTypeSanityCheck(fieldtype) ; } catch(IllegalArgumentException e) { // because this Method's parameter fails the sanity check, its probably not an InetAddress related structure return false ; } Class<?> listType = (Class<?>) fieldtype.getActualTypeArguments()[0] ; return isInetAddressOrCompatibleType(listType) ; } else { // check if the non-parameterized type is InetAddress, InetSocketAddress or IpAddress Class<?> fieldtype = f.getType() ; return isInetAddressOrCompatibleType(fieldtype) ; } } /*
static boolean isInetAddressRelated(Method m) { if (hasParameterizedType(m)) { Type[] types = m.getGenericParameterTypes(); ParameterizedType methodParamType = (ParameterizedType)types[0] ; // check that this parameterized type satisfies our constraints try { parameterizedTypeSanityCheck(methodParamType) ; } catch(IllegalArgumentException e) { // because this Method's parameter fails the sanity check, its probably not an InetAddress return false ; } Class<?> listType = (Class<?>) methodParamType.getActualTypeArguments()[0] ; return isInetAddressOrCompatibleType(listType) ; } else { Class<?> methodParamType = m.getParameterTypes()[0] ; return isInetAddressOrCompatibleType(methodParamType) ; } } static boolean isInetAddressOrCompatibleType(Class<?> c) {
public List<InetAddress> getInetAddresses() { List<InetAddress> addresses = new ArrayList<>() ; if (getConvertedValue() == null) return addresses ; // if we take only an InetAddress argument if (!isParameterized()) { addresses.add(getInetAddress(getConvertedValue())) ; return addresses ; } // if we take a List<InetAddress> or similar else { List<?> values = (List<?>) getConvertedValue() ; if (values.isEmpty()) return addresses ; for (int i = 0; i < values.size(); i++) { addresses.add(getInetAddress(values.get(i))) ; } return addresses ; } }
public String toString() { StringBuilder sb = new StringBuilder() ; sb.append("InetAddressInfo(") .append("protocol=" + protocol.getName()) .append(", propertyName=" + getPropertyName()) .append(", string value=" + getStringValue()) .append(", parameterized=" + isParameterized()); if (isParameterized()) sb.append(", baseType=" + getBaseType()) ; sb.append(")") ; return sb.toString(); } }
if (isField()) propertyName=PropertyHelper.getPropertyName((Field)fieldOrMethod, properties) ; else if (isField()) this.isParameterized = hasParameterizedType((Field)fieldOrMethod) ; else this.isParameterized = hasParameterizedType((Method)fieldOrMethod) ; if (isField() && isParameterized) { else if (!isField() && isParameterized) {
static boolean isInetAddressRelated(Field f) { if (hasParameterizedType(f)) { // check for List<InetAddress>, List<InetSocketAddress>, List<IpAddress> ParameterizedType fieldtype = (ParameterizedType) f.getGenericType() ; // check that this parameterized type satisfies our constraints try { parameterizedTypeSanityCheck(fieldtype) ; } catch(IllegalArgumentException e) { // because this Method's parameter fails the sanity check, its probably not an InetAddress related structure return false ; } Class<?> listType = (Class<?>) fieldtype.getActualTypeArguments()[0] ; return isInetAddressOrCompatibleType(listType) ; } else { // check if the non-parameterized type is InetAddress, InetSocketAddress or IpAddress Class<?> fieldtype = f.getType() ; return isInetAddressOrCompatibleType(fieldtype) ; } } /*
/** * Returns all inet addresses found */ public static Collection<InetAddress> getAddresses(Map<String, Map<String, InetAddressInfo>> inetAddressMap) throws Exception { Set<InetAddress> addrs=new HashSet<>(); for(Map.Entry<String, Map<String, InetAddressInfo>> inetAddressMapEntry : inetAddressMap.entrySet()) { Map<String, InetAddressInfo> protocolInetAddressMap=inetAddressMapEntry.getValue(); for(Map.Entry<String, InetAddressInfo> protocolInetAddressMapEntry : protocolInetAddressMap.entrySet()) { InetAddressInfo inetAddressInfo=protocolInetAddressMapEntry.getValue(); // add InetAddressInfo to sets based on IP version List<InetAddress> addresses=inetAddressInfo.getInetAddresses(); for(InetAddress address : addresses) { if(address == null) throw new RuntimeException("failed converting address info to IP address: " + inetAddressInfo); addrs.add(address); } } } return addrs; }
static boolean isInetAddressRelated(Method m) { if (hasParameterizedType(m)) { Type[] types = m.getGenericParameterTypes(); ParameterizedType methodParamType = (ParameterizedType)types[0] ; // check that this parameterized type satisfies our constraints try { parameterizedTypeSanityCheck(methodParamType) ; } catch(IllegalArgumentException e) { // because this Method's parameter fails the sanity check, its probably not an InetAddress return false ; } Class<?> listType = (Class<?>) methodParamType.getActualTypeArguments()[0] ; return isInetAddressOrCompatibleType(listType) ; } else { Class<?> methodParamType = m.getParameterTypes()[0] ; return isInetAddressOrCompatibleType(methodParamType) ; } } static boolean isInetAddressOrCompatibleType(Class<?> c) {