Validates a MappedClass

@param mappedClass the MappedClass to validate
@param mapper the Mapper to use for validation
187381
@Deprecated
    public void validate(final Mapper mapper, final MappedClass mappedClass) {
        validate(mapper, singletonList(mappedClass));
    }
883277
public void checkLonelyValidatorAnnotation(Field field, Map<String, Class<?>> genericMap) {
        doCheckLonelyValidatorAnnotation(field, deriveFieldType(field, genericMap));
    }
1273689
public function setMapper(KeyMapperInterface $mapper)
	{
		$this->mapper = $mapper;
		$this->mapper->setDelimiter($this->delimiter);
	}
1281225
public void validate(Columns columns) {
        for (Mapper mapper : mappers.values()) {
            mapper.validate(columns);
        }
    }
763460
protected void discover(final Mapper mapper) {
        for (final Class<? extends Annotation> c : INTERESTING_ANNOTATIONS) {
            addAnnotation(c);
        }

        Class<?> superclass = clazz.getSuperclass();
        if (superclass != null && !superclass.equals(Object.class)) {
            superClass = mapper.getMappedClass(superclass);
        }
        for (Class<?> aClass : clazz.getInterfaces()) {
            interfaces.add(mapper.getMappedClass(aClass));
        }

        final List<Class<?>> lifecycleClasses = new ArrayList<Class<?>>();
        lifecycleClasses.add(clazz);

        final EntityListeners entityLisAnn = (EntityListeners) getAnnotation(EntityListeners.class);
        if (entityLisAnn != null && entityLisAnn.value().length != 0) {
            Collections.addAll(lifecycleClasses, entityLisAnn.value());
        }

        for (final Class<?> cls : lifecycleClasses) {
            for (final Method m : ReflectionUtils.getDeclaredAndInheritedMethods(cls)) {
                for (final Class<? extends Annotation> c : LIFECYCLE_ANNOTATIONS) {
                    if (m.isAnnotationPresent(c)) {
                        addLifecycleEventMethod(c, m, cls.equals(clazz) ? null : cls);
                    }
                }
            }
        }

        update();

        for (final java.lang.reflect.Field field : ReflectionUtils.getDeclaredAndInheritedFields(clazz, true)) {
            field.setAccessible(true);
            final int fieldMods = field.getModifiers();
            if (!isIgnorable(field, fieldMods, mapper)) {
                if (field.isAnnotationPresent(Id.class)) {
                    persistenceFields.add(new MappedField(field, clazz, mapper));
                    update();
                } else if (field.isAnnotationPresent(Property.class)
                           || field.isAnnotationPresent(Reference.class)
                           || field.isAnnotationPresent(Embedded.class)
                           || field.isAnnotationPresent(Serialized.class)
                           || isSupportedType(field.getType())
                           || ReflectionUtils.implementsInterface(field.getType(), Serializable.class)) {
                    persistenceFields.add(new MappedField(field, clazz, mapper));
                } else {
                    if (mapper.getOptions().getDefaultMapper() != null) {
                        persistenceFields.add(new MappedField(field, clazz, mapper));
                    } else if (LOG.isWarnEnabled()) {
                        LOG.warn(format("Ignoring (will not persist) field: %s.%s [type:%s]", clazz.getName(), field.getName(),
                                           field.getType().getName()));
                    }
                }
            }
        }
    }
878034
public static void addTypeMapper(Class<?> clz, Class<?> mapper) {
		synchronized (classMapper) {
			LinkedHashSet<Class<?>> h = classMapper.get(clz);
			if (h == null) {
				h = new LinkedHashSet<Class<?>>();
				classMapper.put(clz, h);
			}
			
			h.add(mapper);
		}
	}
237058
private void validate() {
        if(driverClass == null) {
            throw new IllegalArgumentException("Driver class must be specified");
        }
        if(catalog == null || catalog.isEmpty()) {
            throw new IllegalArgumentException("Schema name must be specified");
        }
        if(table == null || table.isEmpty()) {
            throw new IllegalArgumentException("Table name must be specified");
        }
        if(connectionUrl == null || connectionUrl.isEmpty()) {
            if((host != null && !host.isEmpty()) && (port > 0)) {
                connectionUrl(getJdbcUrl());
            } else {
                throw new IllegalArgumentException("You must specify at least one of connectionUrl or host and port properties");
            }
        }
        if(partitionKey == null && numPartitions > 1) {
            throw new IllegalArgumentException("You must define a valid partition key for using more than one partition.");
        }
    }
220521
public static Map mapKeys(Mapper mapper, Map map) {
        return mapKeys(mapper, map, false);
    }
741940
private Mapper initializeMapper() {
    try {
      return MapperFactory.getInstance().getMapper(field);
    } catch (NoSuitableMapperException exp) {
      String message = String.format(
          "No suitable mapper found or error occurred creating a mapper for field %s in class %s",
          field.getName(), field.getDeclaringClass().getName());
      throw new NoSuitableMapperException(message, exp);
    }
  }
55221
@Override
    // TODO: reduce Cyclomatic complexity
    public final void validate(final Class<?> clazz)
    {

        if (classes.contains(clazz))
        {
            return;
        }

        if (log.isDebugEnabled())
            log.debug("Validating " + clazz.getName());

        // Is Entity?
//        if (clazz.isAnnotationPresent(MappedSuperclass.class))
//        {
//            throw new InvalidEntityDefinitionException("JPA operation over MappedSuperclass are not allowed" + clazz);
//        }
        
        
        // Is Entity?
        if (!clazz.isAnnotationPresent(Entity.class))
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " is not annotated with @Entity.");
        }

        
        // TODO:: add validation for MappedSuperClass.
        
//        // Must be annotated with @Table
//        if (!clazz.isAnnotationPresent(Table.class))
//        {
//            throw new InvalidEntityDefinitionException(clazz.getName() + " must be annotated with @Table.");
//        }

        // must have a default no-argument constructor
        try
        {
            clazz.getConstructor();
        }
        catch (NoSuchMethodException nsme)
        {
            throw new InvalidEntityDefinitionException(clazz.getName()
                    + " must have a default no-argument constructor.");
        }

        // Check for @Key and ensure that there is just 1 @Key field of String
        // type.
        List<Field> keys = new ArrayList<Field>();
        for (Field field : clazz.getDeclaredFields())
        {
            if (field.isAnnotationPresent(Id.class) && field.isAnnotationPresent(EmbeddedId.class))
            {
                throw new InvalidEntityDefinitionException(clazz.getName()
                        + " must have either @Id field or @EmbeddedId field");
            }

            if (field.isAnnotationPresent(Id.class))
            {
                keys.add(field);
                // validate @GeneratedValue annotation if given
                if (field.isAnnotationPresent(GeneratedValue.class))
                {
                    validateGeneratedValueAnnotation(clazz, field);
                }
            }
            else if (field.isAnnotationPresent(EmbeddedId.class))
            {
                keys.add(field);
            }
        }

        if (keys.size() < 0)
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " must have an @Id field.");
        }
        else if (keys.size() > 1)
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " can only have 1 @Id field.");
        }

        // save in cache

        classes.add(clazz);
    }
257379
protected function buildMapping($mappedClass)
    {
        return (\is_string($mappedClass) && \class_exists($mappedClass, true)) ?
            MappingFactory::fromClass($mappedClass) :
            MappingFactory::fromArray($mappedClass);
    }
1368410
public void setMapperClass(Class<? extends Mapper> cls
                             ) throws IllegalStateException {
    ensureState(JobState.DEFINE);
    conf.setClass(MAP_CLASS_ATTR, cls, Mapper.class);
  }
510002
@SuppressWarnings("unchecked")
	static <E, M extends BinderMapper<E>> M getMapper(Class<E> cls) {
		M mapper = (M) OBJECT_MAPPERS.get(cls);
		if (mapper == null) {
			// The only way the mapper wouldn't already be loaded into
			// OBJECT_MAPPERS is if it was compiled separately, but let's handle
			// it anyway
			String beanClassName = cls.getName();
			String mapperClassName = cls.getName() + KriptonBinder.MAPPER_CLASS_SUFFIX;
			try {
				Class<E> mapperClass = (Class<E>) Class.forName(mapperClassName);
				mapper = (M) mapperClass.newInstance();
				// mapper.
				OBJECT_MAPPERS.put(cls, mapper);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
				throw new KriptonRuntimeException(String.format("Class '%s' does not exist. Does '%s' have @BindType annotation?", mapperClassName, beanClassName));
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return mapper;
	}
1297552
private static synchronized <D,S> IMapper<D,S> createMapper(MapperBuilder mapper) throws Throwable{
	    
		Class<Mapper<D,S>> mapperClass = mapper.exist()?mapper.<D,S>get()
				                                       :mapper.<D,S>generate();
		return mapperClass.newInstance();
	}
1081775
private static ConcurrentHashMap<Class, List<ParamValidator>> getValidatorsMap() {

        // use <ConcurrentHashMap> in case validators are added while initializing parameters through <getValidator> method.
        ConcurrentHashMap<Class, List<ParamValidator>> map = new ConcurrentHashMap();
        addValidators(map, ParamValidator.class,    new ParamValidator(true),   new ParamValidator(false)); // default validator
        addValidators(map, FileValidator.class,     new FileValidator(true),    new FileValidator(false));
        addValidators(map, URLValidator.class,      new URLValidator(true),     new URLValidator(false));
        addValidators(map, HEXValidator.class,      new HEXValidator(true),     new HEXValidator(false));

        return map;
    }
700281
public function addDiscriminatorMapClass($name, string $className) : void
    {
        $this->discriminatorMap[$name] = $className;

        if ($this->className === $className) {
            $this->discriminatorValue = $name;

            return;
        }

        if (! (class_exists($className) || interface_exists($className))) {
            throw MappingException::invalidClassInDiscriminatorMap($className, $this->className);
        }

        if (is_subclass_of($className, $this->className) && ! in_array($className, $this->subClasses, true)) {
            $this->subClasses[] = $className;
        }
    }
1159167
public Operation createMappedOperationForDeepFetch(Mapper mapper)
    {
        Operation rootOperation = this.getRootOperation();
        if (rootOperation == null) return null;
        return mapper.createMappedOperationForDeepFetch(rootOperation);
    }