本文整理汇总了Java中io.fabric8.utils.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于io.fabric8.utils包,在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
// lets ignore the mission validation as its not suitable for fabric8
// super.validate(context);
if (github == null || !github.isDetailsValid()) {
// invoked too early before the github account is setup - lets return silently
return;
}
String orgName = getOrganisationName(gitOrganisation.getValue());
String repoName = getGithubRepositoryNameValue();
if (Strings.isNotBlank(orgName)) {
if (Strings.isNotBlank(repoName)) {
github.validateRepositoryName(getNamed(), context, orgName, repoName);
}
}
}
示例2: GitRepositoryDTO
import io.fabric8.utils.Strings; //导入依赖的package包/类
public GitRepositoryDTO(String key, GHRepository repository) {
this.id = key;
this.name = repository.getName();
if (Strings.isNullOrBlank(name)) {
name = repository.getFullName();
}
if (Strings.isNullOrBlank(name)) {
name = key;
}
description = repository.getDescription();
if (Strings.isNullOrBlank(description) || key.equals(description)) {
try {
description = createdAtText(repository.getCreatedAt());
} catch (IOException e) {
// ignore
}
}
if (Strings.isNullOrBlank(description)) {
description = repository.getHomepage();
}
}
示例3: initializeUI
import io.fabric8.utils.Strings; //导入依赖的package包/类
public void initializeUI(final UIBuilder builder) throws Exception {
super.initializeUI(builder);
this.github = gitHubFacadeFactory.createGitHubFacade(builder.getUIContext());
// TODO cache this per user every say 30 seconds!
Collection<GitOrganisationDTO> organisations = new ArrayList<>();
if (github != null && github.isDetailsValid()) {
String orgKey = github.getDetails().getUserCacheKey();
organisations = organisationsCache.computeIfAbsent(orgKey, k -> github.loadGitHubOrganisations());
}
gitOrganisation.setValueChoices(organisations);
gitOrganisation.setItemLabelConverter(GitOrganisationDTO::getId);
String userName = github.getDetails().getUsername();
if (Strings.isNotBlank(userName)) {
for (GitOrganisationDTO organisation : organisations) {
if (userName.equals(organisation.getName())) {
gitOrganisation.setDefaultValue(organisation);
break;
}
}
}
if (organisations.size() > 1) {
builder.add(gitOrganisation);
}
}
示例4: getEmail
import io.fabric8.utils.Strings; //导入依赖的package包/类
public String getEmail() {
String email = details.getEmail();
if (Strings.isNullOrBlank(email)) {
GHMyself gitMyself = getMyself();
if (gitMyself != null) {
try {
email = gitMyself.getEmail();
if (Strings.isNullOrBlank(email)) {
LOG.warn("No email found on the user settings or GitHub myself, default to invalid address");
// github user might have chosen to keep email address private
// populate it with invalid address as null is invalid for org.eclipse.jgit.lib.PersonIdent
email = "[email protected]";
}
} catch (IOException e) {
LOG.warn("Could not get github.getMyself().getEmail(): " + e, e);
}
}
}
return email;
}
示例5: createRepository
import io.fabric8.utils.Strings; //导入依赖的package包/类
public GHRepository createRepository(String orgName, String repoName, String description) throws IOException {
GHCreateRepositoryBuilder builder;
if (Strings.isNullOrBlank(orgName) || orgName.equals(details.getUsername())) {
builder = github.createRepository(repoName);
} else {
builder = github.getOrganization(orgName).createRepository(repoName);
}
// TODO link to the space URL?
builder.private_(false)
.homepage("")
.issues(false)
.downloads(false)
.wiki(false);
if (Strings.isNotBlank(description)) {
builder.description(description);
}
return builder.create();
}
示例6: getUserName
import io.fabric8.utils.Strings; //导入依赖的package包/类
/**
* Returns the current users kubernetes/openshift user name
*/
public String getUserName() {
OpenShiftClient oc = getOpenShiftClientOrNull();
if (oc != null) {
User user = oc.users().withName("~").get();
if (user == null) {
LOG.warn("Failed to find current logged in user!");
} else {
String answer = KubernetesHelper.getName(user);
if (Strings.isNullOrBlank(answer)) {
LOG.warn("No name for User " + user);
} else {
return answer;
}
}
}
// TODO needs to use the current token to find the current user name
return Configs.currentUserName();
}
示例7: ensureSpaceLabelAddedToPom
import io.fabric8.utils.Strings; //导入依赖的package包/类
private static boolean ensureSpaceLabelAddedToPom(Document document, String spaceId) {
if (document != null && Strings.isNotBlank(spaceId)) {
NodeList plugins = document.getElementsByTagName("plugin");
if (plugins != null) {
for (int i = 0, size = plugins.getLength(); i < size; i++) {
Node item = plugins.item(i);
if (item instanceof Element) {
Element element = (Element) item;
if ("fabric8-maven-plugin".equals(DomHelper.firstChildTextContent(element, "artifactId"))) {
String indent = "\n ";
Element configuration = getOrCreateChild(element, "configuration", indent);
Element resources = getOrCreateChild(configuration, "resources", indent + " ");
Element labels = getOrCreateChild(resources, "labels", indent + " ");
Element all = getOrCreateChild(labels, "all", indent + " ");
Element space = getOrCreateChild(all, "space", indent + " ");
if (!spaceId.equals(space.getTextContent())) {
space.setTextContent(spaceId);
return true;
}
}
}
}
}
}
return false;
}
示例8: testSingleUpdate
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Test
public void testSingleUpdate() throws Exception {
String dependency = "cheese";
String version = "1.2.3";
PushVersionChanges command = new PushVersionChanges(NPM, dependency, version);
parentContext.updateVersion(NPM, dependency, version);
assertContextCommandComment(command,
COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency, version));
String comment = command.createPullRequestComment();
CompositeCommand parsedCommands = parseCommandComment(comment, 1);
PushVersionChanges parsedUpdateVersion = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
CommandAssertions.assertPushVersionContext(parsedUpdateVersion, NPM, dependency, version);
}
示例9: testTwoUpdates
import io.fabric8.utils.Strings; //导入依赖的package包/类
@Test
public void testTwoUpdates() throws Exception {
String dependency1 = "beer";
String version1 = "2.3.4";
String dependency2 = "wine";
String version2 = "4.5.6";
PushVersionChanges command = new PushVersionChanges(NPM, dependency1, version1, dependency2, version2);
assertContextCommandComment(command,
COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency1, version1, dependency2, version2));
String comment = command.createPullRequestComment();
CompositeCommand parsedCommands = parseCommandComment(comment, 1);
PushVersionChanges parsedUpdateVersion1 = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
CommandAssertions.assertPushVersionContext(parsedUpdateVersion1, NPM, dependency1, version1, dependency2, version2);
}
示例10: assertPluginVersionChanged
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static void assertPluginVersionChanged(File file, Document doc, DependencyVersionChange change) {
boolean found = false;
List<Element> elements = findElementsWithName(doc.getRootElement(), "plugin");
for (Element element : elements) {
String groupId = firstChildTextContent(element, "groupId");
String artifactId = firstChildTextContent(element, "artifactId");
String version = firstChildTextContent(element, "version");
if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
if (change.matches(groupId, artifactId)) {
found = true;
if (!version.startsWith("$")) {
LOG.info("File " + file + " has plugin " + change.getDependency() + " version: " + version);
assertThat(version).describedAs("File " + file + " plugin version for " + change.getDependency()).isEqualTo(change.getVersion());
}
}
}
}
assertThat(found).describedAs("File " + file + " does not have plugin " +
change.getDependency() + " version: " + change.getVersion()).isTrue();
}
示例11: assertDependencyVersionChanged
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static void assertDependencyVersionChanged(File file, Document doc, DependencyVersionChange change) {
boolean found = false;
List<Element> elements = findElementsWithName(doc.getRootElement(), "dependency");
for (Element element : elements) {
String groupId = firstChildTextContent(element, "groupId");
String artifactId = firstChildTextContent(element, "artifactId");
String version = firstChildTextContent(element, "version");
if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
if (change.matches(groupId, artifactId)) {
found = true;
if (!version.startsWith("$")) {
LOG.info("File " + file + " has dependency " + change.getDependency() + " version: " + version);
assertThat(version).describedAs("File " + file + " dependency version for " + change.getDependency()).isEqualTo(change.getVersion());
}
}
}
}
/*
assertThat(found).describedAs("File " + file + " does not have dependency " +
change.getDependency() + " version: " + change.getVersion()).isTrue();
*/
}
示例12: getArchetypesFromJar
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected List<String> getArchetypesFromJar(File archetypeJar) throws IOException {
assertThat(archetypeJar).exists();
JarFile jar = new JarFile(archetypeJar);
String entryName = "archetype-catalog.xml";
ZipEntry entry = jar.getEntry(entryName);
assertThat(entry).describedAs("Missing entry " + entryName + " in jar " + archetypeJar).isNotNull();
SortedSet<String> artifactIds = new TreeSet<>();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(jar.getInputStream(entry));
Document doc = builder.parse(is);
NodeList artifactTags = doc.getElementsByTagName("artifactId");
for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
Node element = artifactTags.item(i);
String artifactId = element.getTextContent();
if (Strings.isNotBlank(artifactId)) {
artifactIds.add(artifactId);
}
}
} catch (Exception e) {
fail("Failed to parse " + entryName + " in jar " + archetypeJar + ". Exception " + e, e);
}
return new ArrayList<>(artifactIds);
}
示例13: getArchetypesFromJar
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected List<String> getArchetypesFromJar() throws IOException {
String entryName = "archetype-catalog.xml";
URL url = getClass().getClassLoader().getResource(entryName);
assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();
SortedSet<String> artifactIds = new TreeSet<>();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(url.openStream());
Document doc = builder.parse(is);
NodeList artifactTags = doc.getElementsByTagName("artifactId");
for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
Node element = artifactTags.item(i);
String artifactId = element.getTextContent();
if (Strings.isNotBlank(artifactId)) {
artifactIds.add(artifactId);
}
}
} catch (Exception e) {
fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
}
return new ArrayList<>(artifactIds);
}
示例14: unshellifyName
import io.fabric8.utils.Strings; //导入依赖的package包/类
/**
* A name of the form "foo-bar-whatnot" is turned into "Foo: Bar Whatnot"
*/
public static String unshellifyName(String name) {
if (Strings.isNotBlank(name)) {
if (name.indexOf('-') >= 0 && name.toLowerCase().equals(name)) {
String[] split = name.split("-");
StringBuffer buffer = new StringBuffer();
int idx = 0;
for (String part : split) {
if (idx == 1) {
buffer.append(": ");
} else if (idx > 1) {
buffer.append(" ");
}
buffer.append(capitalize(part));
idx++;
}
return buffer.toString();
}
}
return name;
}
示例15: getResultMessage
import io.fabric8.utils.Strings; //导入依赖的package包/类
protected static String getResultMessage(Result result) {
if (result instanceof CompositeResult) {
CompositeResult compositeResult = (CompositeResult) result;
List<Result> results = compositeResult.getResults();
StringBuilder buffer = new StringBuilder();
for (Result childResult : results) {
String childResultMessage = getResultMessage(childResult);
if (Strings.isNotBlank(childResultMessage)) {
if (buffer.length() > 0) {
buffer.append("\n");
}
buffer.append(childResultMessage);
}
}
return buffer.toString();
} else if (result != null) {
return result.getMessage();
} else {
return null;
}
}