public static <S extends IWidget> IDepthFirstTreeVisitor<S> functionToVisitor(Function<S, TreeVisitResult> visitor) { assertNotNull(visitor); return new DepthFirstTreeVisitor<S>() { @Override public TreeVisitResult preVisit(S widget, int level, int index) { return visitor.apply(widget); } }; }
public JsonLookupCallResult(ILookupCallResult<T> result, boolean multipleColumns, Function<T, ? extends Object> keyMapper) { Assertions.assertNotNull(result); m_result = result; m_multipleColumns = multipleColumns; m_keyMapper = keyMapper; }
/** * @param cacheKey * not null * @param resource * not null */ public HttpCacheObject(HttpCacheKey cacheKey, BinaryResource resource) { Assertions.assertNotNull(cacheKey); Assertions.assertNotNull(resource); m_cacheKey = cacheKey; m_resource = resource; }
public JsonLookupRow(ILookupRow<T> lookupRow, boolean multipleColumns, Function<T, ? extends Object> keyMapper) { Assertions.assertNotNull(lookupRow); m_lookupRow = lookupRow; m_multipleColumns = multipleColumns; m_keyMapper = keyMapper; }
public TreeEventMerger(TreeEvent targetEvent) { m_targetEvent = assertNotNull(targetEvent, "targetEvent must not be null"); m_mergedNodes = new LinkedList<>(); }
@Override public void openUri(String url, IOpenUriAction openUriAction) { Assertions.assertNotNull(url); Assertions.assertNotNull(openUriAction); fireOpenUri(url, openUriAction); }
/** * Reads the reply-destination used in 'request-reply' communication, or throws {@link AssertionException} if not set. * * @see JmsMessageWriter#writeReplyTo(Destination) */ public Destination readReplyTo() throws JMSException { final Destination replyTo = m_message.getJMSReplyTo(); return assertNotNull(replyTo, "missing 'replyTo' [msg={}]", m_message); }
@Override public <DTO> ISubscription subscribe(final IDestination<DTO> destination, final IMessageListener<DTO> listener, final SubscribeInput input) { assertNotNull(destination, "destination not specified"); assertNotNull(listener, "messageListener not specified"); assertNotNull(input, "input not specified"); try { return subscribeImpl(destination, listener, input); } catch (final JMSException e) { throw BEANS.get(DefaultRuntimeExceptionTranslator.class).translate(e); } }
public TableEventMerger(TableEvent targetEvent) { assertNotNull(targetEvent, "targetEvent must not be null"); m_targetEvent = targetEvent; m_targetColumns = targetEvent.getColumns(); m_targetColumnSet = new HashSet<>(m_targetColumns); m_mergedColumns = new LinkedList<>(); m_targetRows = targetEvent.getRows(); m_targetRowSet = new HashSet<>(m_targetRows); m_mergedRows = new LinkedList<>(); }
@Override public <T extends IWidget> void visit(Consumer<T> visitor, Class<T> type) { assertNotNull(visitor); visit(new WidgetVisitorTypeAdapter<>(widget -> { visitor.accept(widget); return TreeVisitResult.CONTINUE; }, type)); }
/** * @return transaction member for publishing messages within a transaction */ protected ClusterSynchTransactionMember getTransaction() { ITransaction tx = Assertions.assertNotNull(ITransaction.CURRENT.get(), "Transaction required"); ClusterSynchTransactionMember m = (ClusterSynchTransactionMember) tx.getMember(TRANSACTION_MEMBER_ID); if (m == null) { m = new ClusterSynchTransactionMember(TRANSACTION_MEMBER_ID); tx.registerMember(m); } return m; }
private void publish(List<ClientNotificationMessage> notifications) { if (tryPiggyBack(notifications)) { m_notificationRegistry.publish(notifications, Assertions.assertNotNull(IClientNodeId.CURRENT.get(), "Missing 'client node id' on current calling context")); } else { m_notificationRegistry.publish(notifications); } }
@Override public void showFileChooser(IFileChooser fileChooser) { if (fileChooser == null || m_fileChooserStore.contains(fileChooser)) { return; } // Ensure 'displayParent' to be set. Assertions.assertNotNull(fileChooser.getDisplayParent(), "Property 'displayParent' must not be null"); m_fileChooserStore.add(fileChooser); fireFileChooserShow(fileChooser); }
@Override public void setFormat(DecimalFormat format) { Assertions.assertNotNull(format); DecimalFormat newFormat = (DecimalFormat) format.clone(); newFormat.setParseBigDecimal(true); propertySupport.setProperty(INumberValueContainer.PROP_DECIMAL_FORMAT, newFormat); updateDisplayTexts(); }
@Override public void start(String sessionId) { Assertions.assertFalse(m_stopping, "Session cannot be started again"); Assertions.assertNotNull(sessionId, "Session id must not be null"); if (isActive()) { throw new IllegalStateException("session is active"); } m_id = sessionId; interceptLoadSession(); setActive(true); fireSessionChangedEvent(new SessionEvent(this, SessionEvent.TYPE_STARTED)); LOG.info("Client session started [session={}, user={}]", this, getUserId()); }
@Override public void setDisplayParent(IDisplayParent displayParent) { Assertions.assertFalse(ClientSessionProvider.currentSession().getDesktop().isShowing(this), "Property 'displayParent' cannot be changed because FileChooser is already showing [fileChooser={}]", this); if (displayParent == null) { displayParent = BEANS.get(DisplayParentResolver.class).resolve(this); } m_displayParent = Assertions.assertNotNull(displayParent, "'displayParent' must not be null"); }
@Override public IMessageBox withDisplayParent(IDisplayParent displayParent) { Assertions.assertFalse(ClientSessionProvider.currentSession().getDesktop().isShowing(this), "Property 'displayParent' cannot be changed because message box is already showing [messageBox={}]", this); if (displayParent == null) { displayParent = BEANS.get(DisplayParentResolver.class).resolve(this); } m_displayParent = Assertions.assertNotNull(displayParent, "'displayParent' must not be null"); return this; }
/** * Validates the given {@link RunContext} to be valid for model jobs. */ public void validateRunContext(final RunContext runContext) { Assertions.assertTrue(runContext instanceof ClientRunContext, "A model job requires a ClientRunContext"); Assertions.assertNotNull(((ClientRunContext) runContext).getSession(), "A model job requires a ClientSession in the ClientRunContext"); Assertions.assertEquals(1, ((ClientRunContext) runContext).getSession().getModelJobSemaphore().getPermits(), "A model job requires a semaphore with permit size 1 for mutual exclusion"); }
/** * Validates the given {@link JobInput} to be valid for model jobs. */ public void validateJobInput(final JobInput input) { Assertions.assertNotNull(input, "A model job requires a job input"); validateRunContext(input.getRunContext()); Assertions.assertSame(((ClientRunContext) input.getRunContext()).getSession().getModelJobSemaphore(), input.getExecutionSemaphore(), "A model job requires the session's model job semaphore"); } }
@Override protected void onJmsMessage(final Message jmsRequest) throws JMSException { final String replyId = assertNotNull(jmsRequest.getStringProperty(JMS_PROP_REPLY_ID), "missing 'replyId' [msg={}]", jmsRequest); // Read and process the message asynchronously because JMS session is single-threaded. This allows concurrent message processing. // Unlike AutoAcknowledgeSubscriptionStrategy, a job is scheduled for 'single-threaded' mode to support cancellation (execution hint). final IFuture<Void> future = Jobs.schedule(() -> { handleMessageInRunContext(jmsRequest, replyId); }, m_mom.newJobInput() .withName("Receiving JMS message [dest={}]", m_destination) .withExecutionHint(replyId)); // Register for cancellation if (isSingleThreaded()) { future.awaitDone(); } }