/** * Registers an enum. Returns true if registration is successful. */ public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass) { return null == enumMapping.putIfAbsent(enumClass.getName(), EnumIO.newEnumIO(enumClass, this)); }
/** * Registers an enum. Returns true if registration is successful. */ public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass) { return null == enumMapping.putIfAbsent(enumClass.getName(), EnumIO.newEnumIO(enumClass, this)); }
@Override protected EnumIO<? extends Enum<?>> getEnumIO(Class<?> enumClass) { EnumIO<?> eio = enumMapping.get(enumClass.getName()); if (eio == null) { eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent( enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
@Override protected EnumIO<? extends Enum<?>> getEnumIO(Class<?> enumClass) { EnumIO<?> eio = enumMapping.get(enumClass.getName()); if (eio == null) { eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent( enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
private EnumIO<? extends Enum<?>> getEnumIO(String className, boolean load) { EnumIO<?> eio = enumMapping.get(className); if (eio == null) { if (!load) return null; final Class<?> enumClass = RuntimeEnv.loadClass(className); eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent( enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
private EnumIO<? extends Enum<?>> getEnumIO(String className, boolean load) { EnumIO<?> eio = enumMapping.get(className); if (eio == null) { if (!load) return null; final Class<?> enumClass = RuntimeEnv.loadClass(className); eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent( enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
private RuntimeEnumIO getRuntimeEnumIO(Class<?> enumClass) { RuntimeEnumIO reio = enumMapping.get(enumClass); if (reio == null) { reio = new RuntimeEnumIO(); final RuntimeEnumIO existing = enumMapping.putIfAbsent(enumClass, reio); if (existing != null) reio = existing; else { reio.eio = EnumIO.newEnumIO(enumClass, this); int id = enumId.getAndIncrement(); enums.set(id, reio); // commit reio.id = id; } } return reio; }
/** * Enum ids start at 1. */ @Override public <T extends Enum<T>> Registry registerEnum(Class<T> clazz, int id) { if (id < 1) throw new IllegalArgumentException("enum ids start at 1."); if (id >= strategy.enumIdStart) throw new IllegalArgumentException("enum ids must be lesser than " + strategy.enumIdStart); else if (strategy.enums.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + clazz.getName() + ")"); } EnumIO<?> eio = EnumIO.newEnumIO(clazz, strategy); RuntimeEnumIO reio = new RuntimeEnumIO(); reio.id = id; reio.eio = eio; strategy.enums.set(id, reio); // just in case if (strategy.enumMapping.put(clazz, reio) != null) throw new IllegalArgumentException("Duplicate registration for: " + clazz); return this; }
/** * Enum ids start at 1. */ @Override public <T extends Enum<T>> Registry registerEnum(Class<T> clazz, int id) { if (id < 1) throw new IllegalArgumentException("enum ids start at 1."); if (id >= strategy.enums.size()) grow(strategy.enums, id + 1); else if (strategy.enums.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + clazz.getName() + ")"); } EnumIO<?> eio = EnumIO.newEnumIO(clazz, strategy); RegisteredEnumIO reio = new RegisteredEnumIO(id, eio); strategy.enums.set(id, reio); // just in case if (strategy.enumMapping.put(clazz, reio) != null) throw new IllegalArgumentException("Duplicate registration for: " + clazz); return this; }
/** * Registers an enum. Returns true if registration is successful. */ public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass) { return null == enumMapping.putIfAbsent(enumClass.getName(), EnumIO.newEnumIO(enumClass, this)); }
@Override protected EnumIO<? extends Enum<?>> getEnumIO(Class<?> enumClass) { EnumIO<?> eio = enumMapping.get(enumClass.getName()); if (eio == null) { eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent(enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
private EnumIO<? extends Enum<?>> getEnumIO(String className, boolean load) { EnumIO<?> eio = enumMapping.get(className); if (eio == null) { if (!load) return null; final Class<?> enumClass = RuntimeEnv.loadClass(className); eio = EnumIO.newEnumIO(enumClass, this); final EnumIO<?> existing = enumMapping.putIfAbsent(enumClass.getName(), eio); if (existing != null) eio = existing; } return eio; }
private RuntimeEnumIO getRuntimeEnumIO(Class<?> enumClass) { RuntimeEnumIO reio = enumMapping.get(enumClass); if (reio == null) { reio = new RuntimeEnumIO(); final RuntimeEnumIO existing = enumMapping.putIfAbsent(enumClass, reio); if (existing != null) reio = existing; else { reio.eio = EnumIO.newEnumIO(enumClass, this); int id = enumId.getAndIncrement(); enums.set(id, reio); // commit reio.id = id; } } return reio; }
/** * Enum ids start at 1. */ @Override public <T extends Enum<T>> Registry registerEnum(Class<T> clazz, int id) { if (id < 1) throw new IllegalArgumentException("enum ids start at 1."); if (id >= strategy.enumIdStart) throw new IllegalArgumentException("enum ids must be lesser than " + strategy.enumIdStart); else if (strategy.enums.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + clazz.getName() + ")"); } EnumIO<?> eio = EnumIO.newEnumIO(clazz, strategy); RuntimeEnumIO reio = new RuntimeEnumIO(); reio.id = id; reio.eio = eio; strategy.enums.set(id, reio); // just in case if (strategy.enumMapping.put(clazz, reio) != null) throw new IllegalArgumentException("Duplicate registration for: " + clazz); return this; }
/** * Enum ids start at 1. */ @Override public <T extends Enum<T>> Registry registerEnum(Class<T> clazz, int id) { if (id < 1) throw new IllegalArgumentException("enum ids start at 1."); if (id >= strategy.enums.size()) grow(strategy.enums, id + 1); else if (strategy.enums.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + clazz.getName() + ")"); } EnumIO<?> eio = EnumIO.newEnumIO(clazz, strategy); RegisteredEnumIO reio = new RegisteredEnumIO(id, eio); strategy.enums.set(id, reio); // just in case if (strategy.enumMapping.put(clazz, reio) != null) throw new IllegalArgumentException("Duplicate registration for: " + clazz); return this; }