/** * Returns the {@link MediaPeriodInfo} of the media period at the end of the queue which is * currently loading or will be the next one loading. May be null, if no media period is active * yet. */ public @Nullable MediaPeriodInfo getLoadingMediaPeriod() { return mediaPeriodInfoQueue.isEmpty() ? null : mediaPeriodInfoQueue.get(mediaPeriodInfoQueue.size() - 1); }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, callbacks -> { ArrayList<Callback> list = new ArrayList<>(Arrays.asList(callbacks)); final Iterator<Callback> iterator = list.iterator(); while (iterator.hasNext()) { Callback callback = iterator.next(); if (callback instanceof ChannelBindingCallback) { ((ChannelBindingCallback) callback).setBindingType(bindingType); ((ChannelBindingCallback) callback).setBindingData(bindingData); iterator.remove(); } } if (!list.isEmpty()) { cbh.handle(list.toArray(new Callback[list.size()])); } }); }
@Override public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) { discontinuityReasons.add(reason); int currentIndex = player.getCurrentPeriodIndex(); if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION || periodIndices.isEmpty() || periodIndices.get(periodIndices.size() - 1) != currentIndex) { // Ignore seek or internal discontinuities within a period. periodIndices.add(currentIndex); } }
public void recover(ConnectionContext context, Topic topic, SubscriptionRecovery sub) throws Exception { // Re-dispatch the messages from the buffer. ArrayList<TimestampWrapper> copy = new ArrayList<TimestampWrapper>(buffer); if (!copy.isEmpty()) { for (Iterator<TimestampWrapper> iter = copy.iterator(); iter.hasNext();) { TimestampWrapper timestampWrapper = iter.next(); MessageReference message = timestampWrapper.message; sub.addRecoveredMessage(context, message); } } }
public static String[] getNodeElements( Node node ) { ArrayList<String> elements = new ArrayList<String>(); // List of String NodeList nodeList = node.getChildNodes(); if ( nodeList == null ) { return null; } for ( int i = 0; i < nodeList.getLength(); i++ ) { String nodeName = nodeList.item( i ).getNodeName(); if ( elements.indexOf( nodeName ) < 0 ) { elements.add( nodeName ); } } if ( elements.isEmpty() ) { return null; } return elements.toArray( new String[ elements.size() ] ); }
/** * Ends all pending and ongoing transitions on the specified scene root. * * @param sceneRoot The root of the View hierarchy to end transitions on. */ public static void endTransitions(final @NonNull ViewGroup sceneRoot) { sPendingTransitions.remove(sceneRoot); final ArrayList<Transition> runningTransitions = getRunningTransitions(sceneRoot); if (!runningTransitions.isEmpty()) { // Make a copy in case this is called by an onTransitionEnd listener ArrayList<Transition> copy = new ArrayList(runningTransitions); for (int i = copy.size() - 1; i >= 0; i--) { final Transition transition = copy.get(i); transition.forceToEnd(sceneRoot); } } }
@Override public List<byte[]> getStripeBoundaries() { if (this.state.stripeFiles.isEmpty()) { return Collections.emptyList(); } ArrayList<byte[]> result = new ArrayList<>(this.state.stripeEndRows.length + 2); result.add(OPEN_KEY); Collections.addAll(result, this.state.stripeEndRows); result.add(OPEN_KEY); return result; }
@Override protected void verifyResultsIdealCircumstances(ListSink sink) { ArrayList<Integer> list = new ArrayList<>(); for (int x = 1; x <= 60; x++) { list.add(x); } for (Integer i : sink.values) { list.remove(i); } Assert.assertTrue("The following ID's where not found in the result list: " + list.toString(), list.isEmpty()); Assert.assertTrue("The sink emitted to many values: " + (sink.values.size() - 60), sink.values.size() == 60); }
/** * @apilevel internal */ private boolean isDUafterReachedFinallyBlocks_compute(Variable v) { if(!isDUbefore(v) && finallyList().isEmpty()) return false; for(Iterator iter = finallyList().iterator(); iter.hasNext(); ) { FinallyHost f = (FinallyHost)iter.next(); if(!f.isDUafterFinally(v)) return false; } return true; } protected java.util.Map isDAafterReachedFinallyBlocks_Variable_values;
public GradientPanel (GradientColorValue value, String name, String description, boolean hideGradientEditor) { super(value, name, description); this.value = value; initializeComponents(); if (hideGradientEditor) { gradientEditor.setVisible(false); } gradientEditor.percentages.clear(); for (float percent : value.getTimeline()) gradientEditor.percentages.add(percent); gradientEditor.colors.clear(); float[] colors = value.getColors(); for (int i = 0; i < colors.length;) { float r = colors[i++]; float g = colors[i++]; float b = colors[i++]; gradientEditor.colors.add(new Color(r, g, b)); } if (gradientEditor.colors.isEmpty() || gradientEditor.percentages.isEmpty()) { gradientEditor.percentages.clear(); gradientEditor.percentages.add(0f); gradientEditor.percentages.add(1f); gradientEditor.colors.clear(); gradientEditor.colors.add(Color.white); } setColor(gradientEditor.colors.get(0)); }
@Override public void compress() { if (images == null || images.isEmpty()) { listener.onCompressFailed(images, " images is null"); return; } for (TImage image : images) { if (image == null) { listener.onCompressFailed(images, " There are pictures of compress is null."); return; } files.add(new File(image.getOriginalPath())); } if (images.size() == 1) { compressOne(); } else { compressMulti(); } }
private static InterceptorList ofList(final ArrayList<EJBClientInterceptorInformation> value) { if (value.isEmpty()) { return EMPTY; } else if (value.size() == 1) { return value.get(0).getSingletonList(); } else { return new InterceptorList(value.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS)); } }
/** * Add a named argument. * @param name the name of the argument. * @param parse an optional function to transform the string to something else. If null a NOOP is used. * @param assoc an association command to decide what to do if the argument appears multiple times. If null INTO_LIST is used. * @return a builder to be used to continue creating the command line. */ public CLIBuilder arg(String name, Parse parse, Assoc assoc) { if (!optionalArgs.isEmpty()) { throw new IllegalStateException("Cannot have a required argument after adding in an optional argument"); } args.add(new Arg(name, parse, assoc)); return this; }
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { if (e == null) { return AnAction.EMPTY_ARRAY; } Project project = e.getProject(); Editor editor = e.getData(CommonDataKeys.EDITOR); if (project == null || editor == null) return AnAction.EMPTY_ARRAY; PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); ArrayList<AnAction> children = ContainerUtil.newArrayList(); for (GoTestFramework framework : GoTestFramework.all()) { if (framework.isAvailableOnFile(file)) { children.addAll(framework.getGenerateMethodActions()); } } return !children.isEmpty() ? children.toArray(new AnAction[children.size()]) : AnAction.EMPTY_ARRAY; } }
if (!extensionHandshakers.isEmpty()) { p.addBefore("handler", "websocketsExtensionsHandler", new WebSocketClientExtensionHandler( extensionHandshakers.toArray(new WebSocketClientExtensionHandshaker[extensionHandshakers.size()]))); handshaker = WebSocketClientHandshakerFactory.newHandshaker(wsuri, version, subProtocols, !extensionHandshakers.isEmpty(), nettyHeaders, maxWebSocketFrameSize,!options.isSendUnmaskedFrames(),false);
/** * Updates the queue with a released media period. Returns whether the media period was still in * the queue. */ public boolean onMediaPeriodReleased(MediaPeriodId mediaPeriodId) { MediaPeriodInfo mediaPeriodInfo = mediaPeriodIdToInfo.remove(mediaPeriodId); if (mediaPeriodInfo == null) { // The media period has already been removed from the queue in resetForNewMediaSource(). return false; } mediaPeriodInfoQueue.remove(mediaPeriodInfo); if (readingMediaPeriod != null && mediaPeriodId.equals(readingMediaPeriod.mediaPeriodId)) { readingMediaPeriod = mediaPeriodInfoQueue.isEmpty() ? null : mediaPeriodInfoQueue.get(0); } return true; }