+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.codec.impl;
-
-import java.io.IOException;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingStreamEventWriter;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * SPI-level contract for implementations of {@link DataObjectSerializer}.
- * The contract is kept between implementation of {@link DataObjectSerializerRegistry},
- * which maintains the lookup context required for recursive serialization.
- */
-//* FIXME: this interface should not be necessary
-public interface DataObjectSerializerImplementation {
- /**
- * Writes stream events for supplied data object to provided stream.
- *
- * <p>
- * DataObjectSerializerRegistry may be used to lookup serializers for other generated classes in order to support
- * writing their events.
- */
- void serialize(DataObjectSerializerRegistry reg, DataObject obj, BindingStreamEventWriter stream)
- throws IOException;
-}
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
- * SPI-level contract for registry of {@link DataObjectSerializer}. The contract is kept between implementation
- * of {@link DataObjectSerializerImplementation}, Registry provides lookup for serializers to support recursive
- * serialization of nested {@link DataObject}s.
+ * SPI-level contract for registry of {@link DataObjectSerializer}. The contract is kept between implementation of
+ * {@link DataObjectSerializer}, Registry provides lookup for serializers to support recursive serialization of nested
+ * {@link DataObject}s.
*/
// FIXME: this interface should not be necessary
public interface DataObjectSerializerRegistry {
* @param <T> DataObject type
*/
@Beta
-public abstract class DataObjectStreamer<T extends DataObject> implements DataObjectSerializerImplementation {
+public abstract class DataObjectStreamer<T extends DataObject> {
private static final Logger LOG = LoggerFactory.getLogger(DataObjectStreamer.class);
protected DataObjectStreamer() {
}
+ /**
+ * Writes stream events for supplied data object to provided stream.
+ *
+ * <p>
+ * DataObjectSerializerRegistry may be used to lookup serializers for other generated classes in order to support
+ * writing their events.
+ */
+ protected abstract void serialize(DataObjectSerializerRegistry reg, DataObject obj, BindingStreamEventWriter stream)
+ throws IOException;
+
protected static final void streamAnydata(final BindingStreamEventWriter writer, final String localName,
final Object value) throws IOException {
if (value != null && writer instanceof AnydataBindingStreamWriter) {
private static final Generic BB_BESV = TypeDefinition.Sort.describe(BindingStreamEventWriter.class);
private static final Generic BB_IOX = TypeDefinition.Sort.describe(IOException.class);
- private static final int PUB_FINAL = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
- private static final int PUB_CONST = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL
- | Opcodes.ACC_SYNTHETIC;
-
private static final Builder<?> TEMPLATE = new ByteBuddy().subclass(DataObjectStreamer.class)
- .modifiers(PUB_FINAL);
+ .modifiers(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC);
private static final StackManipulation REG = MethodVariableAccess.REFERENCE.loadFrom(1);
private static final StackManipulation OBJ = MethodVariableAccess.REFERENCE.loadFrom(2);
}
final GeneratorResult<T> result = GeneratorResult.of(builder
- .defineMethod("serialize", BB_VOID, PUB_FINAL)
+ .defineMethod("serialize", BB_VOID, Opcodes.ACC_PROTECTED | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC)
.withParameters(BB_DOSR, BB_DATAOBJECT, BB_BESV)
.throwing(BB_IOX)
.intercept(new SerializeImplementation(bindingInterface, startEvent, children)).make(), depBuilder.build());
public InstrumentedType prepare(final InstrumentedType instrumentedType) {
return instrumentedType
// private static final This INSTANCE = new This()
- .withField(new FieldDescription.Token(INSTANCE_FIELD, PUB_CONST, instrumentedType.asGenericType()))
+ .withField(new FieldDescription.Token(INSTANCE_FIELD,
+ Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC,
+ instrumentedType.asGenericType()))
.withInitializer(InitializeInstanceField.INSTANCE);
}