Java Code Examples for joptsimple.internal.Strings#isNullOrEmpty()
The following examples show how to use
joptsimple.internal.Strings#isNullOrEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocUtils.java From OpenPeripheral with MIT License | 6 votes |
public static String createPeripheralHelpText(Class<? extends Object> cls, String type, IMethodMap methods) { StringBuilder builder = new StringBuilder(); builder.append("----OpenPeripheral doc----\n"); builder.append("Peripheral type: "); builder.append(type); builder.append("\n\n"); final String docText = DOC_TEXT_CACHE.getOrCreate(cls); if (!Strings.isNullOrEmpty(docText)) { builder.append(docText); builder.append("\n\n"); } builder.append("---Methods---\n"); listMethods(builder, methods); return builder.toString(); }
Example 2
Source File: ClockManager.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
public void loadStopwatches() { final String stopwatchesJson = configManager.getConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.STOPWATCHES); if (!Strings.isNullOrEmpty(stopwatchesJson)) { final Gson gson = new Gson(); final List<Stopwatch> stopwatches = gson.fromJson(stopwatchesJson, new TypeToken<ArrayList<Stopwatch>>() { }.getType()); this.stopwatches.clear(); this.stopwatches.addAll(stopwatches); SwingUtilities.invokeLater(clockTabPanel::rebuild); } }
Example 3
Source File: FastField.java From ForgeHax with MIT License | 6 votes |
@Override protected Field lookup() throws Exception { for (State state : State.values()) { String n = name.getByState(state); if (!Strings.isNullOrEmpty(n)) { try { Field f = insideClass.getDeclaredField(n); f.setAccessible(true); if (stripFinal) { Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); } return f; } catch (Exception e) { } } } return null; }
Example 4
Source File: FastMethod.java From ForgeHax with MIT License | 6 votes |
@Override protected Method lookup() throws Exception { Objects.requireNonNull(parameters); for (State state : State.values()) { String n = name.getByState(state); if (!Strings.isNullOrEmpty(n)) { try { Method m = insideClass.getDeclaredMethod(n, parameters); m.setAccessible(true); return m; } catch (Exception e) { } } } return null; }
Example 5
Source File: DocUtils.java From OpenPeripheral with MIT License | 6 votes |
private static String createDocString(IMethodDescription desc) { // (arg:type[, optionArg:type]):resultType -- Description List<String> args = Lists.newArrayList(); for (IArgumentDescription arg : desc.arguments()) args.add(arg.name() + ":" + decorate(arg.type().describe(), arg)); final IScriptType returnTypes = desc.returnTypes(); String argsJoined = Joiner.on(',').join(args); String argsAndResult; if (TypeHelper.isVoid(returnTypes)) { argsAndResult = String.format("(%s)", argsJoined); } else { final String ret = returnTypes.describe(); argsAndResult = String.format("(%s):%s", argsJoined, ret); } return !Strings.isNullOrEmpty(desc.description())? argsAndResult + " -- " + desc.description() : argsAndResult; }
Example 6
Source File: ClockManager.java From plugins with GNU General Public License v3.0 | 5 votes |
public void loadStopwatches() { final String stopwatchesJson = configManager.getConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.STOPWATCHES); if (!Strings.isNullOrEmpty(stopwatchesJson)) { final Gson gson = new Gson(); final List<Stopwatch> stopwatches = gson.fromJson(stopwatchesJson, new TypeToken<ArrayList<Stopwatch>>() {}.getType()); this.stopwatches.clear(); this.stopwatches.addAll(stopwatches); SwingUtilities.invokeLater(clockTabPanel::rebuild); } }
Example 7
Source File: ElectricBoogaloo.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void itemToolTipEvent(ItemTooltipEvent event) { if (twosList == null || twosList.length < 1 || event.getToolTip().isEmpty()) return; boolean isPotion = event.getItemStack().getItem() instanceof ItemPotion || event.getItemStack().getItem() instanceof ItemArrow; for (int i = 0; i < event.getToolTip().size(); i++) { String toolTip = event.getToolTip().get(i); String lowerTip = toolTip.toLowerCase(); boolean relocateReset = false; if (lowerTip.endsWith("§r")) { lowerTip = lowerTip.substring(0, lowerTip.length() - 2); toolTip = toolTip.substring(0, toolTip.length() - 2); relocateReset = true; } for (String to : twosList) { String boogaloo = null; if (isPotion && TIMER_PATTERN.matcher(lowerTip).find()) { String potionName = lowerTip.substring(0, lowerTip.indexOf('(') - 1); if (potionName.endsWith(to)) { int index = toolTip.indexOf('(') - 1; String beforeTimer = toolTip.substring(0, index); String timer = toolTip.substring(index); boogaloo = I18n.format("tooltip.community_mod.electric", beforeTimer) + timer; } } if (lowerTip.endsWith(to)) { boogaloo = I18n.format("tooltip.community_mod.electric", toolTip); if (relocateReset) boogaloo += "§r"; } if (!Strings.isNullOrEmpty(boogaloo)) event.getToolTip().set(i, boogaloo); } } }
Example 8
Source File: ClockManager.java From plugins with GNU General Public License v3.0 | 5 votes |
public void loadTimers() { final String timersJson = configManager.getConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.TIMERS); if (!Strings.isNullOrEmpty(timersJson)) { final Gson gson = new Gson(); final List<Timer> timers = gson.fromJson(timersJson, new TypeToken<ArrayList<Timer>>() {}.getType()); this.timers.clear(); this.timers.addAll(timers); SwingUtilities.invokeLater(clockTabPanel::rebuild); } }
Example 9
Source File: JmxPortCheck.java From newblog with Apache License 2.0 | 5 votes |
public static String check() { String ipAndPorts = Config.getProperty("jmx_ip_port"); if (!Strings.isNullOrEmpty(ipAndPorts)) { String[] strings = ipAndPorts.split(","); for (String string : strings) { String[] str = string.split(":"); if (getURL(str[0], Integer.parseInt(str[1]))) { return string; } } } return null; }
Example 10
Source File: NotesManager.java From plugins with GNU General Public License v3.0 | 5 votes |
void loadNotes() { final String configJson = configManager.getConfiguration(NotesConfig.CONFIG_GROUP, NotesConfig.NOTES); notes = null; if (!Strings.isNullOrEmpty(configJson)) { final Gson gson = new Gson(); notes = gson.fromJson(configJson, new TypeToken<ArrayList<String>>() {}.getType()); } if (notes == null) { notes = new ArrayList<>(); notes.add(""); } // migrate from legacy single tab notes if (!config.notesData().isEmpty()) { log.info("Adding tab for legacy note data"); notes.add(0, config.notesData()); if (notes.size() == 2 && notes.get(1).equals("")) { // remove the default empty note page notes.remove(1); } } }
Example 11
Source File: SlayerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private boolean taskSubmit(ChatInput chatInput, String value) { if (Strings.isNullOrEmpty(currentTask.getTaskName())) { return false; } final String playerName = client.getLocalPlayer().getName(); executor.execute(() -> { try { chatClient.submitTask(playerName, capsString(currentTask.getTaskName()), currentTask.getAmount(), currentTask.getInitialAmount(), currentTask.getTaskLocation()); } catch (Exception ex) { log.warn("unable to submit slayer task", ex); } finally { chatInput.resume(); } }); return true; }
Example 12
Source File: DiskRegion.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private boolean hasSameCompressor(final RegionAttributes<?,?> ra) { Compressor raCompressor = ra.getCompressor(); if (raCompressor == null) { return Strings.isNullOrEmpty(getCompressorClassName()) ? true : false; } return raCompressor.getClass().getName().equals(getCompressorClassName()); }
Example 13
Source File: SlayerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void addCounter() { if (!config.showInfobox() || counter != null || currentTask == null || Strings.isNullOrEmpty(currentTask.getTaskName())) { return; } Task task = Task.getTask(currentTask.getTaskName()); AsyncBufferedImage taskImg = getImageForTask(task); String taskTooltip = ColorUtil.wrapWithColorTag("%s", new Color(255, 119, 0)) + "</br>"; if (currentTask.getTaskLocation() != null && !currentTask.getTaskLocation().isEmpty()) { taskTooltip += currentTask.getTaskLocation() + "</br>"; } taskTooltip += ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW) + " %s</br>" + ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW) + " %s"; if (currentTask.getInitialAmount() > 0) { taskTooltip += "</br>" + ColorUtil.wrapWithColorTag("Start:", Color.YELLOW) + " " + currentTask.getInitialAmount(); } counter = new TaskCounter(taskImg, this, currentTask.getAmount()); counter.setTooltip(String.format(taskTooltip, capsString(currentTask.getTaskName()), points, streak)); infoBoxManager.addInfoBox(counter); }
Example 14
Source File: KafkaRpcPluginThread.java From opentsdb-rpc-kafka with Apache License 2.0 | 5 votes |
String getPrefix(final String metric) { if (Strings.isNullOrEmpty(metric)) { return DEFAULT_COUNTER_ID; } int idx = metric.indexOf("."); if (idx < 1) { return DEFAULT_COUNTER_ID; } return metric.substring(0, idx); }
Example 15
Source File: SlayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private boolean taskSubmit(ChatInput chatInput, String value) { if (Strings.isNullOrEmpty(taskName)) { return false; } final String playerName = client.getLocalPlayer().getName(); executor.execute(() -> { try { chatClient.submitTask(playerName, capsString(taskName), amount, initialAmount, taskLocation); } catch (Exception ex) { log.warn("unable to submit slayer task", ex); } finally { chatInput.resume(); } }); return true; }
Example 16
Source File: SlayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void addCounter() { if (!config.showInfobox() || counter != null || Strings.isNullOrEmpty(taskName)) { return; } Task task = Task.getTask(taskName); int itemSpriteId = ItemID.ENCHANTED_GEM; if (task != null) { itemSpriteId = task.getItemSpriteId(); } BufferedImage taskImg = itemManager.getImage(itemSpriteId); String taskTooltip = ColorUtil.wrapWithColorTag("%s", new Color(255, 119, 0)) + "</br>"; if (taskLocation != null && !taskLocation.isEmpty()) { taskTooltip += taskLocation + "</br>"; } taskTooltip += ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW) + " %s</br>" + ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW) + " %s"; if (initialAmount > 0) { taskTooltip += "</br>" + ColorUtil.wrapWithColorTag("Start:", Color.YELLOW) + " " + initialAmount; } counter = new TaskCounter(taskImg, this, amount); counter.setTooltip(String.format(taskTooltip, capsString(taskName), config.points(), config.streak())); infoBoxManager.addInfoBox(counter); }
Example 17
Source File: FileHelper.java From ForgeHax with MIT License | 4 votes |
public static String getPathWithoutExtension(String path) { String ext = getFileExtension(path); return !Strings.isNullOrEmpty(ext) ? path.substring(0, path.lastIndexOf("." + ext)) : path; }
Example 18
Source File: SlayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
void taskLookup(ChatMessage chatMessage, String message) { if (!config.taskCommand()) { return; } ChatMessageType type = chatMessage.getType(); final String player; if (type.equals(ChatMessageType.PRIVATECHATOUT)) { player = client.getLocalPlayer().getName(); } else { player = Text.removeTags(chatMessage.getName()) .replace('\u00A0', ' '); } net.runelite.http.api.chat.Task task; try { task = chatClient.getTask(player); } catch (IOException ex) { log.debug("unable to lookup slayer task", ex); return; } if (TASK_STRING_VALIDATION.matcher(task.getTask()).find() || task.getTask().length() > TASK_STRING_MAX_LENGTH || TASK_STRING_VALIDATION.matcher(task.getLocation()).find() || task.getLocation().length() > TASK_STRING_MAX_LENGTH || Task.getTask(task.getTask()) == null || !Task.LOCATIONS.contains(task.getLocation())) { log.debug("Validation failed for task name or location: {}", task); return; } int killed = task.getInitialAmount() - task.getAmount(); StringBuilder sb = new StringBuilder(); sb.append(task.getTask()); if (!Strings.isNullOrEmpty(task.getLocation())) { sb.append(" (").append(task.getLocation()).append(")"); } sb.append(": "); if (killed < 0) { sb.append(task.getAmount()).append(" left"); } else { sb.append(killed).append('/').append(task.getInitialAmount()).append(" killed"); } String response = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append("Slayer Task: ") .append(ChatColorType.HIGHLIGHT) .append(sb.toString()) .build(); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); chatMessageManager.update(messageNode); client.refreshChat(); }
Example 19
Source File: TagProperty.java From ForgeHax with MIT License | 4 votes |
public boolean add(String tag) { return !Strings.isNullOrEmpty(tag) && tags.add(tag); }
Example 20
Source File: TagProperty.java From ForgeHax with MIT License | 4 votes |
public boolean remove(String tag) { return !Strings.isNullOrEmpty(tag) && tags.remove(tag); }