/** * Returns the first partition group that matches the given primitive type. * * @param type the primitive type * @return the first partition group that matches the given primitive type */ @SuppressWarnings("unchecked") default PartitionGroup getPartitionGroup(PrimitiveProtocol.Type type) { return getPartitionGroups().stream() .filter(group -> group.protocol().name().equals(type.name())) .findFirst() .orElse(null); }
/** * Returns the first partition group that matches the given primitive protocol. * * @param protocol the primitive protocol * @return the first partition group that matches the given primitive protocol */ @SuppressWarnings("unchecked") default PartitionGroup getPartitionGroup(ProxyProtocol protocol) { if (protocol.group() != null) { PartitionGroup group = getPartitionGroup(protocol.group()); if (group != null) { return group; } PartitionGroup systemGroup = getSystemPartitionGroup(); if (systemGroup != null && systemGroup.name().equals(protocol.group())) { return systemGroup; } return null; } for (PartitionGroup partitionGroup : getPartitionGroups()) { if (partitionGroup.protocol().name().equals(protocol.type().name())) { return partitionGroup; } } return null; }