/** * Returns a new {@code SudoCommandRegistry}. * * @return the command registry. */ public static SudoCommandRegistry newInstance() { final Map<String, JsonParsable<SudoCommand>> parseStrategies = new HashMap<>(); parseStrategies.put(SudoRetrieveThing.TYPE, SudoRetrieveThing::fromJson); parseStrategies.put(SudoRetrieveThings.TYPE, SudoRetrieveThings::fromJson); return new SudoCommandRegistry(parseStrategies); }
/** * @return the command registry. */ public static BatchStepCommandRegistry newInstance() { final Map<String, JsonParsable<Command>> parseStrategies = toParseStrategies(ThingCommandRegistry.newInstance(), SudoCommandRegistry.newInstance()); return new BatchStepCommandRegistry(parseStrategies); }
private static void addThingsStrategies(final MappingStrategiesBuilder builder) { builder.add(ThingErrorRegistry.newInstance()) .add(ThingCommandRegistry.newInstance()) .add(ThingCommandResponseRegistry.newInstance()) .add(ThingEventRegistry.newInstance()) .add(SudoCommandRegistry.newInstance()) .add(SudoCommandResponseRegistry.newInstance()) .add(StreamingRegistry.newInstance()) .add(Thing.class, (jsonObject) -> ThingsModelFactory.newThing(jsonObject)) // do not replace with lambda! .add(ThingTag.class, jsonObject -> ThingTag.fromJson(jsonObject)) // do not replace with lambda! .add(BatchedEntityIdWithRevisions.typeOf(ThingTag.class), BatchedEntityIdWithRevisions.deserializer(jsonObject -> ThingTag.fromJson(jsonObject))) .build(); }
private static void addThingsStrategies(final MappingStrategiesBuilder builder) { builder .add(ThingErrorRegistry.newInstance()) .add(ThingCommandRegistry.newInstance()) .add(ThingCommandResponseRegistry.newInstance()) .add(ThingEventRegistry.newInstance()) .add(SudoCommandRegistry.newInstance()) .add(SudoCommandResponseRegistry.newInstance()) .add(StreamingRegistry.newInstance()) .add(Thing.class, (jsonObject) -> ThingsModelFactory.newThing(jsonObject)) // do not replace with lambda! .add(ThingTag.class, jsonObject -> ThingTag.fromJson(jsonObject)) // do not replace with lambda! .add(BatchedEntityIdWithRevisions.typeOf(ThingTag.class), BatchedEntityIdWithRevisions.deserializer(jsonObject -> ThingTag.fromJson(jsonObject))) .build(); }
/** * Returns a new {@code SudoCommandRegistry}. * * @return the command registry. */ public static SudoCommandRegistry newInstance() { final Map<String, JsonParsable<SudoCommand>> parseStrategies = new HashMap<>(); parseStrategies.put(SudoRetrieveThing.TYPE, SudoRetrieveThing::fromJson); parseStrategies.put(SudoRetrieveThings.TYPE, SudoRetrieveThings::fromJson); return new SudoCommandRegistry(parseStrategies); }