/** * Figures out the artifact type from the class. * @param artyClass */ private static ArtifactType valueOf(Class<? extends BaseArtifactType> artyClass) { ArtifactType rval = null; for (ArtifactTypeEnum e : ArtifactTypeEnum.values()) { if (e.getTypeClass().equals(artyClass)) { rval = new ArtifactType(e, null); } } return rval; }
@Override public void complete(CompleterInvocation completerInvocation) { String currentValue = completerInvocation.getGivenCompleteValue(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { String candidate = t.getType(); if (StringUtils.isBlank(currentValue) || candidate.startsWith(currentValue)) { completerInvocation.addCompleterValue(candidate); } } } }
/** * Figures out the type from the artifact instance. * @param artifact */ public static ArtifactTypeEnum valueOf(BaseArtifactType artifact) { BaseArtifactEnum apiType = artifact.getArtifactType(); if (apiType != null) { return valueOf(apiType); } ArtifactTypeEnum[] values = values(); for (ArtifactTypeEnum artifactType : values) { if (artifactType.getTypeClass().equals(artifact.getClass())) { return artifactType; } } throw new RuntimeException(Messages.i18n.format("ARTIFACT_TYPE_FROM_CLASS_ERROR", artifact.getClass())); }
/** * Figures out the type from the s-ramp API type. * @param apiType */ public static ArtifactTypeEnum valueOf(BaseArtifactEnum apiType) { ArtifactTypeEnum[] values = values(); for (ArtifactTypeEnum artifactType : values) { if (artifactType.getApiType() == apiType) { return artifactType; } } throw new RuntimeException(Messages.i18n.format("ARTIFACT_TYPE_FROM_APITYPE_ERROR", apiType.value())); }
@Override public void complete(CompleterInvocation completerInvocation) { UploadArtifactCommand command = (UploadArtifactCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) { FileNameCompleterDelegate.complete(completerInvocation); } else if (command.arguments.size() == 1) { String currentValue = completerInvocation.getGivenCompleteValue(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { String candidate = t.getType(); if (StringUtils.isBlank(currentValue) || candidate.startsWith(currentValue)) { completerInvocation.addCompleterValue(candidate); } } } } }
/** * Figures out the type from the s-ramp API type. * @param apiType */ public static ArtifactType valueOf(BaseArtifactEnum apiType) { ArtifactTypeEnum[] values = ArtifactTypeEnum.values(); for (ArtifactTypeEnum artifactType : values) { if (artifactType.getApiType() == apiType) { return new ArtifactType(artifactType, null); } } throw new RuntimeException(Messages.i18n.format("ARTIFACT_TYPE_FROM_APITYPE_ERROR", apiType.value())); }
for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { modelCandidates.add(t.getModel()); String partialModel = split[2]; Set<String> modelCandidates = new TreeSet<>(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { if (t.getModel().startsWith(partialModel)) modelCandidates.add(t.getModel()); String model = split[2]; Set<String> typeCandidates = new TreeSet<>(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { if (t.getModel().equals(model)) { typeCandidates.add(t.getType()); String partialType = split[3]; Set<String> typeCandidates = new TreeSet<>(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { if (t.getModel().equals(model) && t.getType().startsWith(partialType)) { typeCandidates.add(t.getType());
ArtifactTypeEnum[] values = ArtifactTypeEnum.values(); for (ArtifactTypeEnum artifactTypeEnum : values) { if (artifactTypeEnum.getTypeClass().equals(artifact.getClass())) {