public Object getFieldValue(_Fields field) { switch (field) { case TYPE: return Byte.valueOf(getType()); case PATH_ELEMENT: return getPathElement(); case CHILDREN: return getChildren(); case AUTHZ_OBJS: return getAuthzObjs(); } throw new IllegalStateException(); }
private Tuple createTPathEntry(Entry entry, AtomicInteger idCounter, Map<Integer, TPathEntry> idMap) { int myId = idCounter.incrementAndGet(); TPathEntry tEntry = new TPathEntry(entry.getType().getByte(), entry.getPathElement(), new HashSet<Integer>()); if (entry.getAuthzObjs().size() != 0) { tEntry.setAuthzObjs(entry.getAuthzObjs()); } idMap.put(myId, tEntry); return new Tuple(tEntry, myId); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TPathEntry) return this.equals((TPathEntry)that); return false; }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TYPE: return isSetType(); case PATH_ELEMENT: return isSetPathElement(); case CHILDREN: return isSetChildren(); case AUTHZ_OBJS: return isSetAuthzObjs(); } throw new IllegalStateException(); }
public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetType()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); } if (!isSetPathElement()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'pathElement' is unset! Struct:" + toString()); } if (!isSetChildren()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'children' is unset! Struct:" + toString()); } // check for sub-struct validity }
private void buildPathsImageMap(Map<Integer, TPathEntry> nodeMap, TPathEntry node, String path, Map<String, Collection<String>> pathsImage, boolean includeLeadingSlash) { path = path.isEmpty()?node.getPathElement(): (path + node.getPathElement() + "/"); TPathEntry tempNode = node; for(int childVal:node.getChildren()) { node = nodeMap.get(childVal); buildPathsImageMap(nodeMap, node, path, pathsImage, includeLeadingSlash); } if(tempNode.getChildren().isEmpty() && node.getAuthzObjs() != null) { for (String authz : node.getAuthzObjs()) { if (!pathsImage.containsKey(authz)) { pathsImage.put(authz, new LinkedList<>()); } if(includeLeadingSlash) { pathsImage.get(authz).add(path.replaceAll("(/+$)", "")); } else { pathsImage.get(authz).add(path.replaceAll("(^/+)|(/+$)", "")); } } } }
buildPathsImageMap(nodeMap, root, "", pathImage, true); assertEquals("/", root.getPathElement()); assertEquals(9, nodeMap.size());//Tree size assertEquals(1, pathsUpdate.getImgNum()); buildPathsImageMap(nodeMap, root, "", pathImage, true); assertEquals("/", root.getPathElement()); assertEquals(8, nodeMap.size());//Tree size assertEquals(2, pathsUpdate.getImgNum());
boolean this_present_pathElement = true && this.isSetPathElement(); boolean that_present_pathElement = true && that.isSetPathElement(); if (this_present_pathElement || that_present_pathElement) { if (!(this_present_pathElement && that_present_pathElement)) boolean this_present_children = true && this.isSetChildren(); boolean that_present_children = true && that.isSetChildren(); if (this_present_children || that_present_children) { if (!(this_present_children && that_present_children)) boolean this_present_authzObjs = true && this.isSetAuthzObjs(); boolean that_present_authzObjs = true && that.isSetAuthzObjs(); if (this_present_authzObjs || that_present_authzObjs) { if (!(this_present_authzObjs && that_present_authzObjs))
int rootId = pathDump.getRootId(); TPathEntry root = nodeMap.get(rootId); assertEquals("/", root.getPathElement()); List<Integer> children; TPathEntry child = root; children = child.getChildren(); assertEquals(1, children.size()); child = nodeMap.get(children.get(0)); assertEquals(path, child.getPathElement());
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TPathsDump struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.rootId = iprot.readI32(); struct.setRootIdIsSet(true); { org.apache.thrift.protocol.TMap _map54 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.nodeMap = new HashMap<Integer,TPathEntry>(2*_map54.size); for (int _i55 = 0; _i55 < _map54.size; ++_i55) { int _key56; // required TPathEntry _val57; // required _key56 = iprot.readI32(); _val57 = new TPathEntry(); _val57.read(iprot); struct.nodeMap.put(_key56, _val57); } } struct.setNodeMapIsSet(true); } }
private void cloneToTPathEntry(Entry parent, TPathEntry tParent, AtomicInteger counter, Map<Integer, TPathEntry> idMap) { for (Entry child : parent.getChildren().values()) { Tuple childTuple = createTPathEntry(child, counter, idMap); tParent.getChildren().add(childTuple.id); cloneToTPathEntry(child, childTuple.entry, counter, idMap); } }
public void write(org.apache.thrift.protocol.TProtocol oprot, TPathEntry struct) throws org.apache.thrift.TException { struct.validate(); if (struct.isSetAuthzObjs()) { oprot.writeFieldBegin(AUTHZ_OBJS_FIELD_DESC);
public TPathEntry deepCopy() { return new TPathEntry(this); }
if (isSetAuthzObjs()) { if (!first) sb.append(", "); sb.append("authzObjs:");
assertEquals("/", root.getPathElement());
lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType()); if (lastComparison != 0) { return lastComparison; if (isSetType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetPathElement()).compareTo(typedOther.isSetPathElement()); if (lastComparison != 0) { return lastComparison; if (isSetPathElement()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pathElement, typedOther.pathElement); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetChildren()).compareTo(typedOther.isSetChildren()); if (lastComparison != 0) { return lastComparison; if (isSetChildren()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.children, typedOther.children); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetAuthzObjs()).compareTo(typedOther.isSetAuthzObjs()); if (lastComparison != 0) { return lastComparison; if (isSetAuthzObjs()) {
/** * Performs a deep copy on <i>other</i>. */ public TPathEntry(TPathEntry other) { __isset_bitfield = other.__isset_bitfield; this.type = other.type; if (other.isSetPathElement()) { this.pathElement = other.pathElement; } if (other.isSetChildren()) { Set<Integer> __this__children = new HashSet<Integer>(); for (Integer other_element : other.children) { __this__children.add(other_element); } this.children = __this__children; } if (other.isSetAuthzObjs()) { Set<String> __this__authzObjs = new HashSet<String>(); for (String other_element : other.authzObjs) { __this__authzObjs.add(other_element); } this.authzObjs = __this__authzObjs; } }
_val51 = new TPathEntry(); _val51.read(iprot); struct.nodeMap.put(_key50, _val51);
/** * Performs a deep copy on <i>other</i>. */ public TPathsDump(TPathsDump other) { __isset_bitfield = other.__isset_bitfield; this.rootId = other.rootId; if (other.isSetNodeMap()) { Map<Integer,TPathEntry> __this__nodeMap = new HashMap<Integer,TPathEntry>(); for (Map.Entry<Integer, TPathEntry> other_element : other.nodeMap.entrySet()) { Integer other_element_key = other_element.getKey(); TPathEntry other_element_value = other_element.getValue(); Integer __this__nodeMap_copy_key = other_element_key; TPathEntry __this__nodeMap_copy_value = new TPathEntry(other_element_value); __this__nodeMap.put(__this__nodeMap_copy_key, __this__nodeMap_copy_value); } this.nodeMap = __this__nodeMap; } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TPathEntry struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeByte(struct.type); oprot.writeString(struct.pathElement); { oprot.writeI32(struct.children.size()); for (int _iter40 : struct.children) { oprot.writeI32(_iter40); } } BitSet optionals = new BitSet(); if (struct.isSetAuthzObjs()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetAuthzObjs()) { { oprot.writeI32(struct.authzObjs.size()); for (String _iter41 : struct.authzObjs) { oprot.writeString(_iter41); } } } }