package org.opendaylight.yangtools.binding.data.codec.gen.impl;
import com.google.common.base.Preconditions;
-
import org.opendaylight.yangtools.binding.data.codec.gen.spi.AbstractSource;
import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
private static final ClassLoadingStrategy STRATEGY = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+ protected static final String SERIALIZER = "_serializer";
protected static final String STREAM = "_stream";
protected static final String ITERATOR = "_iterator";
protected static final String CURRENT = "_current";
protected Class<? extends DataContainer> loadClass(final Type childType) {
try {
return (Class<? extends DataContainer>) STRATEGY.loadClass(childType);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new IllegalStateException("Could not load referenced class ", e);
}
}
protected final CharSequence leafSetEntryNode(final CharSequence value) {
return invoke(STREAM, "leafSetEntryNode", value);
-
}
protected final CharSequence startContainerNode(final CharSequence type, final CharSequence expected) {
}
protected final CharSequence escape(final String localName) {
- return '"'+localName+'"';
+ return '"' + localName + '"';
}
protected final CharSequence startUnkeyedList(final CharSequence type, final CharSequence expected) {
return invoke(STREAM, "startCase", (localName),expected);
}
-
protected final CharSequence anyxmlNode(final String name, final String value) throws IllegalArgumentException {
return invoke(STREAM, "anyxmlNode", escape(name),name);
}
}
protected final CharSequence forEach(final String iterable,final Type valueType,final CharSequence body) {
- return forEach(iterable,ITERATOR,valueType.getFullyQualifiedName(),CURRENT,body);
+ return forEach(iterable, ITERATOR, valueType.getFullyQualifiedName(), CURRENT, body);
}
protected final CharSequence classReference(final Type type) {
- return new StringBuilder().append(type.getFullyQualifiedName()).append(".class");
+ return type.getFullyQualifiedName() + ".class";
}
protected final CharSequence staticInvokeEmitter(final Type childType, final String name) {
final Class<?> cls;
try {
cls = STRATEGY.loadClass(childType);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new IllegalStateException("Failed to invoke emitter", e);
}
- String className = this.generator.loadSerializerFor(cls) + ".getInstance()";
+ final String className = this.generator.loadSerializerFor(cls) + ".getInstance()";
return invoke(className, AbstractStreamWriterGenerator.SERIALIZE_METHOD_NAME, REGISTRY, name, STREAM);
}
}
\ No newline at end of file