public NetworkMockup() { this.initialFactTemplate = defTemplate("initial-fact", ""); defFacts("initial-fact", "", Arrays.asList(new TemplateContainer<>(initialFactTemplate))); { final Template dummyFact = this.defTemplate("dummy-fact", "used as default value for FACT-ADDRESS"); @SuppressWarnings("unchecked") final FactIdentifier dummyFactIdentifier = new org.jamocha.function.fwa.Assert<>( this, new TemplateContainer[] {new TemplateContainer<>(dummyFact)}) .evaluate(); for (final SlotType type : EnumSet.allOf(SlotType.class)) { switch (type) { case BOOLEAN: defaultValues.put(type, Boolean.FALSE); break; case DATETIME: defaultValues.put(type, ZonedDateTime.now()); break; case DOUBLE: defaultValues.put(type, Double.valueOf(0.0)); break; case LONG: defaultValues.put(type, Long.valueOf(0)); break; case NIL: defaultValues.put(type, null); break; case STRING: defaultValues.put(type, ""); break; case SYMBOL: defaultValues.put(type, this.getScope().getOrCreateSymbol("nil")); break; case FACTADDRESS: defaultValues.put(type, dummyFactIdentifier); break; case BOOLEANS: case DATETIMES: case DOUBLES: case FACTADDRESSES: case LONGS: case NILS: case STRINGS: case SYMBOLS: defaultValues.put(type, Array.newInstance(type.getJavaClass(), 0)); break; } } } }
@Override public Template defTemplate(final String name, final String description, final Slot... slots) { final TemplateMockup temp = new TemplateMockup(name, description, Arrays.asList(slots)); templates.put(name, temp); return temp; }