@Test public void testGetUserId() { Crn crn = Crn.builder() .setService(Crn.Service.IAM) .setAccountId("accountId") .setResourceType(Crn.ResourceType.USER) .setResource("userId") .build(); assertEquals("userId", crn.getUserId()); crn = Crn.builder() .setService(Crn.Service.IAM) .setAccountId("accountId") .setResourceType(Crn.ResourceType.USER) .setResource("externalId/userId") .build(); assertEquals("userId", crn.getUserId()); }
public String getUserId() { checkState(resourceType == ResourceType.USER || resourceType == ResourceType.MACHINE_USER, String.format("CRN %s has no user ID because it is of type %s", toString(), resourceType)); int idx = resource.indexOf('/'); return idx == -1 ? resource : resource.substring(idx + 1); }
Crn { public String getUserId() { checkState(resourceType == ResourceType.USER || resourceType == ResourceType.MACHINE_USER, String.format("CRN %s has no user ID because it is of type %s", toString(), resourceType)); int idx = resource.indexOf('/'); return idx == -1 ? resource : resource.substring(idx + 1); } }
Crn { public String getUserId() { checkState(resourceType == ResourceType.USER || resourceType == ResourceType.MACHINE_USER, String.format("CRN %s has no user ID because it is of type %s", toString(), resourceType)); int idx = resource.indexOf('/'); return idx == -1 ? resource : resource.substring(idx + 1); } Crn(Partition partition,
            Service service,
            Region region,
            String accountId,
            ResourceType resourceType,
            String resource); }
Crn { public String getUserId() { checkState(resourceType == ResourceType.USER || resourceType == ResourceType.MACHINE_USER, String.format("CRN %s has no user ID because it is of type %s", toString(), resourceType)); int idx = resource.indexOf('/'); return idx == -1 ? resource : resource.substring(idx + 1); } Crn(Partition partition,
            Service service,
            Region region,
            String accountId,
            ResourceType resourceType,
            String resource); Partition getPartition(); Service getService(); Region getRegion(); String getAccountId(); ResourceType getResourceType(); String getResource(); String getUserId(); @Override String toString(); @Nullable static Crn fromString(String input); static Crn safeFromString(String input); static boolean isCrn(@Nullable String input); @Override int hashCode(); @Override boolean equals(Object object); static Builder builder(); }
Crn { public String getUserId() { checkState(resourceType == ResourceType.USER || resourceType == ResourceType.MACHINE_USER, String.format("CRN %s has no user ID because it is of type %s", toString(), resourceType)); int idx = resource.indexOf('/'); return idx == -1 ? resource : resource.substring(idx + 1); } Crn(Partition partition,
            Service service,
            Region region,
            String accountId,
            ResourceType resourceType,
            String resource); Partition getPartition(); Service getService(); Region getRegion(); String getAccountId(); ResourceType getResourceType(); String getResource(); String getUserId(); @Override String toString(); @Nullable static Crn fromString(String input); static Crn safeFromString(String input); static boolean isCrn(@Nullable String input); @Override int hashCode(); @Override boolean equals(Object object); static Builder builder();  }