Java Reflection Field Check addFieldClass(String fieldName, Class clazz)

Here you can find the source of addFieldClass(String fieldName, Class clazz)

Description

add Field Class

License

Open Source License

Declaration

public static boolean addFieldClass(String fieldName, Class clazz) 

Method Source Code


//package com.java2s;
//License from project: MIT License 

import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<String, Class> fieldTypeMap = new HashMap<>();

    public static boolean addFieldClass(String fieldName, Class clazz) {
        if (fieldTypeMap.containsKey(fieldName) && fieldTypeMap.get(fieldName) != clazz) {
            System.out.println("Field type inconsistancy '" + fieldName + "' with types : "
                    + fieldTypeMap.get(fieldName) + " and " + clazz);
            return false;
        }/*from   w  w w  .  j  ava2 s  . com*/
        fieldTypeMap.put(fieldName, clazz);
        return true;
    }
}

Related

  1. getAllFieldsNoCache(Class realClass, Class upperClass)
  2. getFieldAttribute(Class entityClass, String fieldName)
  3. getFields(Class klass)
  4. getFieldSize(Class clazz)