@Test public void testVerifyPath() { Parameter p = getAggregateParameter("/yamcs/nm/UDP_FRAME_OUT.tc/cop1Status"); String name = "/yamcs/nm/UDP_FRAME_OUT.tc/cop1Status.m1"; int x = AggregateUtil.findSeparator(name); PathElement[] path = AggregateUtil.parseReference(name.substring(x)); assertTrue(AggregateUtil.verifyPath(p.getParameterType(), path)); }
public static boolean verifyPath(ParameterType parameterType, PathElement[] path) { ParameterType ptype = parameterType; for (PathElement pe : path) { if (pe.getName() != null) { if (!(ptype instanceof AggregateParameterType)) { return false; } Member m = ((AggregateParameterType) ptype).getMember(pe.getName()); if (m == null) { return false; } ptype = (ParameterType) m.getType(); } if (pe.getIndex() != null) { int[] idx = pe.getIndex(); if (!(ptype instanceof ArrayParameterType)) { return false; } ArrayParameterType at = (ArrayParameterType) ptype; if (at.getNumberOfDimensions() != idx.length) { return false; } ptype = (ParameterType) at.getElementType(); } } return true; }
AggregateUtil { public static boolean verifyPath(ParameterType parameterType, PathElement[] path) { ParameterType ptype = parameterType; for (PathElement pe : path) { if (pe.getName() != null) { if (!(ptype instanceof AggregateParameterType)) { return false; } Member m = ((AggregateParameterType) ptype).getMember(pe.getName()); if (m == null) { return false; } ptype = (ParameterType) m.getType(); } if (pe.getIndex() != null) { int[] idx = pe.getIndex(); if (!(ptype instanceof ArrayParameterType)) { return false; } ArrayParameterType at = (ArrayParameterType) ptype; if (at.getNumberOfDimensions() != idx.length) { return false; } ptype = (ParameterType) at.getElementType(); } } return true; } }
AggregateUtil { public static boolean verifyPath(ParameterType parameterType, PathElement[] path) { ParameterType ptype = parameterType; for (PathElement pe : path) { if (pe.getName() != null) { if (!(ptype instanceof AggregateParameterType)) { return false; } Member m = ((AggregateParameterType) ptype).getMember(pe.getName()); if (m == null) { return false; } ptype = (ParameterType) m.getType(); } if (pe.getIndex() != null) { int[] idx = pe.getIndex(); if (!(ptype instanceof ArrayParameterType)) { return false; } ArrayParameterType at = (ArrayParameterType) ptype; if (at.getNumberOfDimensions() != idx.length) { return false; } ptype = (ParameterType) at.getElementType(); } } return true; }  }
AggregateUtil { public static boolean verifyPath(ParameterType parameterType, PathElement[] path) { ParameterType ptype = parameterType; for (PathElement pe : path) { if (pe.getName() != null) { if (!(ptype instanceof AggregateParameterType)) { return false; } Member m = ((AggregateParameterType) ptype).getMember(pe.getName()); if (m == null) { return false; } ptype = (ParameterType) m.getType(); } if (pe.getIndex() != null) { int[] idx = pe.getIndex(); if (!(ptype instanceof ArrayParameterType)) { return false; } ArrayParameterType at = (ArrayParameterType) ptype; if (at.getNumberOfDimensions() != idx.length) { return false; } ptype = (ParameterType) at.getElementType(); } } return true; }  static int findSeparator(String s); static PathElement[] parseReference(String name); static boolean verifyPath(ParameterType parameterType, PathElement[] path); static PartialParameterValue extractMember(ParameterValue pv, PathElement[] path); static void updateMember(ParameterValue pv, PartialParameterValue patch); static Value getMemberValue(Value value, PathElement[] path); static String toString(PathElement[] path); static AggregateParameterType createParameterType(String name, AggregateValue v); }
AggregateUtil { public static boolean verifyPath(ParameterType parameterType, PathElement[] path) { ParameterType ptype = parameterType; for (PathElement pe : path) { if (pe.getName() != null) { if (!(ptype instanceof AggregateParameterType)) { return false; } Member m = ((AggregateParameterType) ptype).getMember(pe.getName()); if (m == null) { return false; } ptype = (ParameterType) m.getType(); } if (pe.getIndex() != null) { int[] idx = pe.getIndex(); if (!(ptype instanceof ArrayParameterType)) { return false; } ArrayParameterType at = (ArrayParameterType) ptype; if (at.getNumberOfDimensions() != idx.length) { return false; } ptype = (ParameterType) at.getElementType(); } } return true; }  static int findSeparator(String s); static PathElement[] parseReference(String name); static boolean verifyPath(ParameterType parameterType, PathElement[] path); static PartialParameterValue extractMember(ParameterValue pv, PathElement[] path); static void updateMember(ParameterValue pv, PartialParameterValue patch); static Value getMemberValue(Value value, PathElement[] path); static String toString(PathElement[] path); static AggregateParameterType createParameterType(String name, AggregateValue v);  }