Preserve the current type's generic information with the specified new
type if they have the same class.
482573
public static Type preserveType(Type currentType, Type newType) {
        Type result = newType;
        if (newType != null && currentType != null &&
            currentType.getObjectClass() == newType.getObjectClass()) {
            if (newType.getGenericType().getGenericType() instanceof Class &&
                !(currentType.getGenericType().getGenericType() instanceof Class)) {
                if (newType.isNonNull() && !currentType.isNonNull()) {
                    result = currentType.toNonNull();
                }
                else if (!newType.isNonNull() && currentType.isNonNull()) {
                    result = currentType.toNullable();
                }
            }
        }

        return result;
    }
589544
private static void mergeWildcardTypes(final List<Type> types, final Type... addition) {
        if (types.isEmpty()) {
            Collections.addAll(types, addition);
            return;
        }
        for (Type add : addition) {
            final Class<?> addClass = GenericsUtils.resolveClass(add);
            final Iterator<Type> it = types.iterator();
            boolean additionApproved = true;
            while (it.hasNext()) {
                final Type type = it.next();
                // it can't contain incompatible generics just because of sane sense (type system will not allow)
                final Class<?> typeClass = GenericsUtils.resolveClass(type);
                if (addClass.isAssignableFrom(typeClass)) {
                    if (TypeUtils.isMoreSpecific(add, type)) {
                        // replace
                        it.remove();
                    } else {
                        // more specific type already contained
                        additionApproved = false;
                    }
                    break;
                }
            }
            if (additionApproved) {
                types.add(add);
            }
        }
    }
1196021
@Override
    public GenericsContext type(final Class<?> type) {
        return type == currentType ? this : new GenericsContext(genericsInfo, type, root);
    }
1200041
public static Class<?> resolveClass(Type genericType, Class<?> targetType) {
        if (genericType instanceof Class) {
            return (Class<?>) genericType;
        } else if (genericType instanceof ParameterizedType) {
            return resolveClass(((ParameterizedType) genericType).getRawType(), targetType);
        } else if (genericType instanceof GenericArrayType) {
            GenericArrayType arrayType = (GenericArrayType) genericType;
            Class<?> compoment = resolveClass(arrayType.getGenericComponentType(), targetType);
            return Array.newInstance(compoment, 0).getClass();
        } else if (genericType instanceof TypeVariable) {
            TypeVariable<?> variable = (TypeVariable<?>) genericType;
            genericType = getTypeVariableMap(targetType).get(variable);
            genericType = genericType == null ? resolveBound(variable) : resolveClass(genericType,
                    targetType);
        }

        return genericType instanceof Class ? (Class<?>) genericType : Unknown.class;
    }
763950
@SuppressWarnings("unchecked")
  public static <T> Class<T> wrap(Class<T> type) {
    return (type.isPrimitive() || type == void.class) ? (Class<T>) PrimitiveToWrappers.get(type) : type;
  }
492390
private static <T> void  setIfNew(Property<T> prop, T newValue)
  {
    if(!Objects.equals(prop.getValue(), newValue))
    {
      prop.setValue(newValue);
    }
  }
55029
static <T> T newInstance(Class<T> cls) {
        try {
            return cls.newInstance();
        } catch (Exception e) {
            throw wrap(e);
        }
    }
1221662
public void set(V newReference, boolean newMark) {
        Pair<V> current = pair;
        if (newReference != current.reference || newMark != current.mark)
            this.pair = Pair.of(newReference, newMark);
    }
927536
def _new_type(cls, args):
        

        fformat = ["%r" if f is None else "%s=%%r" % f for f in args]
        fformat = "(%s)" % ", ".join(fformat)

        class _ResultTuple(cls):
            __slots__ = ()
            _fformat = fformat
            if args:
                for i, a in enumerate(args):
                    if a is not None:
                        vars()[a] = property(itemgetter(i))
                del i, a

        return _ResultTuple
697390
def new(cls, **kwargs):
        
        kwargs = cls.preprocess_kwargs_before_new(kwargs)
        if cls.__mapper__.polymorphic_on is not None:
            discriminator_key = cls.__mapper__.polymorphic_on.name
            discriminator_val = kwargs.get(discriminator_key)
            if discriminator_val is not None and discriminator_val in cls.__mapper__.polymorphic_map:
                actual_cls = cls.__mapper__.polymorphic_map[discriminator_val].class_
                return actual_cls(
                    **subdict(
                        actual_cls._preprocess_params(kwargs),
                        actual_cls.all_settable_keys())
                )
        return cls(**subdict(cls._preprocess_params(kwargs), cls.all_settable_keys()))
795223
private static boolean areEqualWithGenerics(ClassNode a, ClassNode b) {
        if (a==null) return b==null;
        if (!a.equals(b)) return false;
        if (a.isUsingGenerics() && !b.isUsingGenerics()) return false;
        GenericsType[] gta = a.getGenericsTypes();
        GenericsType[] gtb = b.getGenericsTypes();
        if (gta==null && gtb!=null) return false;
        if (gtb==null && gta!=null) return false;
        if (gta!=null && gtb!=null) {
            if (gta.length!=gtb.length) return false;
            for (int i = 0; i < gta.length; i++) {
                GenericsType ga = gta[i];
                GenericsType gb = gtb[i];
                boolean result = ga.isPlaceholder()==gb.isPlaceholder() && ga.isWildcard()==gb.isWildcard();
                result = result && ga.isResolved() && gb.isResolved();
                result = result && ga.getName().equals(gb.getName());
                result = result && areEqualWithGenerics(ga.getType(), gb.getType());
                result = result && areEqualWithGenerics(ga.getLowerBound(), gb.getLowerBound());
                if (result) {
                    ClassNode[] upA = ga.getUpperBounds();
                    if (upA!=null) {
                        ClassNode[] upB = gb.getUpperBounds();
                        if (upB==null || upB.length!=upA.length) return false;
                        for (int j = 0; j < upA.length; j++) {
                            if (!areEqualWithGenerics(upA[j],upB[j])) return false;
                        }
                    }
                }
                if (!result) return false;
            }
        }
        return true;
    }
82930
public void newObject(TypeDesc type) {
        if (type.isArray()) {
            newObject(type, 1);
        } else {
            mInstructions.new NewObjectInstruction(mCp.addConstantClass(type));
        }
    }
246616
static <T> TypeInfoImpl<T> typeInfoFor(T source, Class<T> sourceType,
      InheritingConfiguration configuration) {
    if (configuration.valueAccessStore.getFirstSupportedReader(sourceType) != null)
      return new TypeInfoImpl<T>(source, sourceType, configuration);
    return typeInfoFor(sourceType, configuration);
  }
1254506
public <S extends T> TypeSerializationInfo<T> addTypeInfo( Class<S> clazz, String typeInfo ) {
        typeClassToInfo.put( clazz, typeInfo );
        return this;
    }
1223236
public static <E extends Enum<E>> TypeInformation<E> ENUM(Class<E> enumType) {
		return new EnumTypeInfo<>(enumType);
	}
1072208
public static <T> SameType<T> of(TreeDef<T> treeDef, T expected, T actual) {
		return of(treeDef, expected, treeDef, actual).mapToSame(Function.identity(), Function.identity());
	}
663199
public static <T, U> SameType<T> of(TreeNode<T> expected, TreeDef<U> treeDef, U actual, Function<? super U, ? extends T> mapper) {
		return of(TreeNode.treeDef(), expected, treeDef, actual).mapToSame(TreeNode::getContent, mapper);
	}