X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2Fstatistics%2FOFPMultipartTypes.java;fp=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2Fstatistics%2FOFPMultipartTypes.java;h=0000000000000000000000000000000000000000;hb=64fe0fbca1a6c2b77ad25f568d73a7eb64236d16;hp=d5d0fdc2f93b40e63b03079d7f7d17e293eb2a7c;hpb=8b9a3ff2bbc83941254b46b818cbbae5cc1a3a5b;p=openflowjava.git diff --git a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/statistics/OFPMultipartTypes.java b/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/statistics/OFPMultipartTypes.java deleted file mode 100644 index d5d0fdc2..00000000 --- a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/statistics/OFPMultipartTypes.java +++ /dev/null @@ -1,343 +0,0 @@ -package org.openflow.codec.protocol.statistics; - -import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; - -import org.openflow.codec.protocol.Instantiable; -import org.openflow.codec.protocol.OFPType; -import org.openflow.codec.util.U16; - -/** - * Represents an ofp_multipart_types enum - * - * @author AnilGujele - * - */ -public enum OFPMultipartTypes { - DESC(0, OFPDescriptionStatistics.class, OFPDescriptionStatistics.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPDescriptionStatistics(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPDescriptionStatistics(); - } - }), FLOW(1, OFPFlowStatisticsRequest.class, OFPFlowStatisticsReply.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPFlowStatisticsRequest(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPFlowStatisticsReply(); - } - }), AGGREGATE(2, OFPAggregateStatisticsRequest.class, OFPAggregateStatisticsReply.class, - new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPAggregateStatisticsRequest(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPAggregateStatisticsReply(); - } - }), TABLE(3, OFPTableStatistics.class, OFPTableStatistics.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPTableStatistics(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPTableStatistics(); - } - }), PORT_STATS(4, OFPPortStatisticsRequest.class, OFPPortStatisticsReply.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPPortStatisticsRequest(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPPortStatisticsReply(); - } - }), QUEUE(5, OFPQueueStatisticsRequest.class, OFPQueueStatisticsReply.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPQueueStatisticsRequest(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPQueueStatisticsReply(); - } - }), GROUP_DESC(7, OFPGroupDescription.class, OFPGroupDescription.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPGroupDescription(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPGroupDescription(); - } - }), GROUP_FEATURES(8, OFPGroupFeatures.class, OFPGroupFeatures.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPGroupFeatures(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPGroupFeatures(); - } - }), TABLE_FEATURES(12, OFPTableFeatures.class, OFPTableFeatures.class, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPTableFeatures(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPTableFeatures(); - } - }), PORT_DESC(13, OFPPortDescriptionStatistics.class, OFPPortDescriptionStatistics.class, - new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPPortDescriptionStatistics(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPPortDescriptionStatistics(); - } - }), - - EXPERIMENTER(0xffff, OFPExperimenterMultipartHeader.class, OFPExperimenterMultipartHeader.class, - new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPExperimenterMultipartHeader(); - } - }, new Instantiable() { - @Override - public OFPStatistics instantiate() { - return new OFPExperimenterMultipartHeader(); - } - }); - - private static Map requestMapping; - private static Map replyMapping; - - private Class requestClass; - private Constructor requestConstructor; - private Instantiable requestInstantiable; - private Class replyClass; - private Constructor replyConstructor; - private Instantiable replyInstantiable; - private int type; - - /** - * Store some information about the OpenFlow Statistic type, including wire - * protocol type number, and derived class - * - * @param type - * Wire protocol number associated with this OFPMultipartType - * @param requestClass - * The Multipart Java class to return when the containing OFPType - * is MULTIPART_REQUEST - * @param replyClass - * The Multipart Java class to return when the containing OFPType - * is MULTIPART_REPLY - */ - OFPMultipartTypes(int type, Class requestClass, Class replyClass, - Instantiable requestInstantiable, Instantiable replyInstantiable) { - this.type = type; - this.requestClass = requestClass; - try { - this.requestConstructor = requestClass.getConstructor(new Class[] {}); - } catch (Exception e) { - throw new RuntimeException("Failure getting constructor for class: " + requestClass, e); - } - - this.replyClass = replyClass; - try { - this.replyConstructor = replyClass.getConstructor(new Class[] {}); - } catch (Exception e) { - throw new RuntimeException("Failure getting constructor for class: " + replyClass, e); - } - this.requestInstantiable = requestInstantiable; - this.replyInstantiable = replyInstantiable; - OFPMultipartTypes.addMapping(this.type, OFPType.MULTIPART_REQUEST, this); - OFPMultipartTypes.addMapping(this.type, OFPType.MULTIPART_REPLY, this); - } - - /** - * Adds a mapping from type value to OFStatisticsType enum - * - * @param i - * OpenFlow wire protocol type - * @param t - * type of containing OFPMessage, only accepts MULTIPART_REQUEST - * or MULTIPART_REPLY - * @param st - * type - */ - public static void addMapping(int i, OFPType t, OFPMultipartTypes st) { - - if (t == OFPType.MULTIPART_REQUEST) { - if (requestMapping == null) - requestMapping = new HashMap(); - OFPMultipartTypes.requestMapping.put(i, st); - } else if (t == OFPType.MULTIPART_REPLY) { - if (replyMapping == null) - replyMapping = new HashMap(); - OFPMultipartTypes.replyMapping.put(i, st); - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } - - /** - * Remove a mapping from type value to OFPMultipartType enum - * - * @param i - * OpenFlow wire protocol type - * @param t - * type of containing OFPMessage, only accepts MULTIPART_REQUEST - * or MULTIPART_REPLY - */ - public static void removeMapping(int i, OFPType t) { - if (t == OFPType.MULTIPART_REQUEST) { - requestMapping.remove(i); - } else if (t == OFPType.MULTIPART_REPLY) { - replyMapping.remove(i); - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } - - /** - * Given a wire protocol OpenFlow type number, return the OFPMultipartType - * associated with it - * - * @param i - * wire protocol number - * @param t - * type of containing OFPMessage, only accepts MULTIPART_REQUEST - * or MULTIPART_REPLY - * @return OFPMultipartType enum type - */ - public static OFPMultipartTypes valueOf(short i, OFPType t) { - if (t == OFPType.MULTIPART_REQUEST) { - return requestMapping.get(U16.f(i)); - } else if (t == OFPType.MULTIPART_REPLY) { - return replyMapping.get(U16.f(i)); - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } - - /** - * @return Returns the wire protocol value corresponding to this - * OFPMultipartType - */ - public short getTypeValue() { - return U16.t(this.type); - } - - /** - * @return Returns the wire protocol unsigned value corresponding to this - * OFPMultipartType - */ - public int getTypeValueU() { - return this.type; - } - - /** - * @param t - * type of containing OFPMessage, only accepts MULTIPART_REQUEST - * or MULTIPART_REPLY - * @return return the OFPMessage subclass corresponding to this - * OFPMultipartType - */ - public Class toClass(OFPType t) { - if (t == OFPType.MULTIPART_REQUEST) { - return requestClass; - } else if (t == OFPType.MULTIPART_REPLY) { - return replyClass; - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } - - /** - * Returns the no-argument Constructor of the implementation class for this - * OFPMultipartType, either request or reply based on the supplied OFPType - * - * @param t - * @return - */ - public Constructor getConstructor(OFPType t) { - if (t == OFPType.MULTIPART_REQUEST) { - return requestConstructor; - } else if (t == OFPType.MULTIPART_REPLY) { - return replyConstructor; - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } - - /** - * @return the requestInstantiable - */ - public Instantiable getRequestInstantiable() { - return requestInstantiable; - } - - /** - * @param requestInstantiable - * the requestInstantiable to set - */ - public void setRequestInstantiable(Instantiable requestInstantiable) { - this.requestInstantiable = requestInstantiable; - } - - /** - * @return the replyInstantiable - */ - public Instantiable getReplyInstantiable() { - return replyInstantiable; - } - - /** - * @param replyInstantiable - * the replyInstantiable to set - */ - public void setReplyInstantiable(Instantiable replyInstantiable) { - this.replyInstantiable = replyInstantiable; - } - - /** - * Returns a new instance of the implementation class for this - * OFPMultipartType, either request or reply based on the supplied OFPType - * - * @param t - * @return - */ - public OFPStatistics newInstance(OFPType t) { - if (t == OFPType.MULTIPART_REQUEST) { - return requestInstantiable.instantiate(); - } else if (t == OFPType.MULTIPART_REPLY) { - return replyInstantiable.instantiate(); - } else { - throw new RuntimeException(t.toString() + " is an invalid OFPType"); - } - } -}