Create a janitor
@param type The type
@return The janitor
350802
public static Janitor createJanitor(String type)
   {
      if (type == null || type.equals(""))
         return new MinimalJanitor();

      type = type.toLowerCase(Locale.US);
      
      switch (type)
      {
         case "minimal":
            return new MinimalJanitor();
         case "full":
            return new FullJanitor();
         default:
         {
            return new MinimalJanitor();
         }
      }
   }
1260650
public static <T> Writer<T> writer(Format type, OutputStream out, Map<Class, WriteHandler<?, ?>> customHandlers) {
        return writer(type, out, customHandlers, null);
    }
1283343
public static <T> Typed<T> wrap(final Type type) {
        return new Typed<T>() {
            @Override
            public Type getType() {
                return type;
            }
        };
    }
161730
public static Object createInstanceByType(Class<?> type, Object... args) throws Exception {
		if (args.length == 0) {
			Constructor<?> constructor = type.getConstructor();
			return constructor.newInstance();
		} else {
			throw new UnsupportedException(null, "NOT_SUPPORTED", "Constructors with parameters are not supported");
		}
	}
1123388
public static <T extends Annotation> T create(Class<T> annotationType) {
    return new Builder<T>(annotationType).create();
  }
1245915
public <T> BinarySerializer<T> build(Class<T> type) {
		SerializerForType[] serializerForTypes = new SerializerForType[0];
		return build(type, serializerForTypes);
	}
1326408
public static <T> Writer<T> writer(Format type, OutputStream out, WriteHandler<?, ?> defaultWriteHandler) {
        return writer(type, out, null, defaultWriteHandler);
    }
1332993
public static <T> T newInstance(Type type) {
        try {
            Class<T> clazz = (Class<T>) getClass(type);
            if (clazz == null) {
                return null;
            }
            return clazz.newInstance();
        } catch (Exception e) {
            log.warn("new instance fail :{}", e.getCause().toString());
            throw new NewInstanceException(e.getCause().toString());
        }
    }
163933
@SuppressWarnings("unchecked") // types must agree
  public static <T> T createMockObject(Type type) {
    Class<T> rawType;

    if (type instanceof ParameterizedType) {
      rawType = (Class<T>) ((ParameterizedType) type).getRawType();
    } else if (type instanceof Class) {
      rawType = (Class<T>) type;
    } else {
      throw new UnsupportedOperationException("Unsupported type: "
          + type.getClass().getSimpleName());
    }
    T instance = instantiateObject(rawType);

    return populateObject(instance);
  }
662580
public static <T> FnSetOf<T> of(final Type<T> type) {
        return new FnSetOf<T>(type);
    }
637094
public static <T extends Descriptor> T create(final Class<T> type) throws IllegalArgumentException {
        return create(type, null);
    }
291310
public JSType createOptionalNullableType(JSType type) {
    return createUnionType(type, getNativeType(JSTypeNative.VOID_TYPE),
        getNativeType(JSTypeNative.NULL_TYPE));
  }
727163
public <S extends Service> S getService(Class<S> type) {
		for (final Service serv : this.serviceManager.servicesByState().values()) {
			if (serv.isRunning() && type.isInstance(serv)) {
				return type.cast(serv);
			}
		}
		return null;
	}
1039992
@SuppressWarnings("unchecked")
    public static <T> Class<T> erasure(Type type) {
        return EraserVisitor.ERASER.visit(type);
    }
370308
public static ElementBuilder[] newBuilders(Class<?> type) {

		List<ElementBuilder> builders = new ArrayList<ElementBuilder>();

		for (ElementBuilderFactory factory : loader) {
			ElementBuilder b = factory.newBuilder(type);
			if (b != null) {
				builders.add(b);
			}
		}
		return builders.toArray(new ElementBuilder[0]);
	}
970419
public static JcPrimitive fromType(Class<?> type, String name) {
		// TODO what about dates and arrays
		if (type.equals(String.class))
			return new JcString(name);
		else if (type.equals(Number.class))
			return new JcNumber(name);
		else if (type.equals(Boolean.class))
			return new JcBoolean(name);
		return null;
	}
513231
@SuppressWarnings("unchecked")
    public <T> PathBuilder<T> create(Class<T> type) {
        PathBuilder<T> rv = (PathBuilder<T>) paths.get(type);
        if (rv == null) {
            rv = new PathBuilder<T>(type, variableName(type));
            paths.put(type, rv);
        }
        return rv;
    }