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); } }; }
protected void assertWritable() { Assertions.assertFalse(m_readOnly, "Object is read-only"); }
public JmsTransactionMember withSessionProvider(IJmsSessionProvider sessionProvider) throws JMSException { m_sessionProvider = sessionProvider; m_transactedSession = sessionProvider.getSession(); assertNotNull(m_transactedSession); assertTrue(m_transactedSession.getTransacted()); return this; }
protected void extractResolveMethod(final URI uri) { final String rawMethod = uri.getScheme(); Assertions.assertNotNullOrEmpty(rawMethod, "Resolve method not specified, please use format [resolve-method]:///[destination-name] [{}]", m_rawValue); m_resolveMethod = Assertions.assertNotNull(ResolveMethod.parse(rawMethod), "Unknown resolve method: '{}' [{}]", rawMethod, m_rawValue); }
/** * Looks up a destination via JNDI. */ protected Destination lookupJmsDestination(final IDestination<?> destination) throws NamingException { final Object object = Assertions.assertNotNull(createContext().lookup(destination.getName())); final Class<?> expectedType = (destination.getType() == DestinationType.QUEUE ? Queue.class : Topic.class); Assertions.assertInstance(object, expectedType, "The looked up destination is of type '{}', but expected type '{}' [{}]", object.getClass().getName(), expectedType.getName(), destination); return (Destination) object; }
Assertions.assertNotNull(responseSequenceNo); Assertions.assertNotNull(response); Assertions.assertFalse(m_responses.containsKey(responseSequenceNo), "ResponseSequenceNo #{} already registered", responseSequenceNo); if (requestSequenceNo != null) { // optional Assertions.assertFalse(m_requestToResponseMap.containsKey(requestSequenceNo), "RequestSequenceNo #{} already registered", requestSequenceNo); Assertions.assertFalse(m_responseToRequestMap.containsKey(responseSequenceNo), "ResponseSequenceNo #{} already registered", responseSequenceNo);
@Override public <REQUEST, REPLY> REPLY request(final IBiDestination<REQUEST, REPLY> destination, final REQUEST requestObject, final PublishInput input) { assertTrue(m_requestReplyEnabled, "'request-reply' messaging is not enabled for this MOM"); assertNotNull(destination, "destination not specified"); assertNotNull(input, "publishInput not specified"); assertFalse(input.isTransactional(), "transactional mode not supported for 'request-reply' communication");
/** * 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"); }
public static void addField(IFormField f, ICompositeField compositeField, List<IFormField> fields) { assertNotNull(f); assertNotNull(compositeField); assertNotNull(fields); assertNull(f.getParentField(), "field is already contained in '{}'.", f.getParentField()); Assertions.assertTrue(f.getForm() == null || f.getForm() == compositeField.getForm(), "field is part of a different form, '{}' instead of '{}'", f.getForm(), compositeField.getForm()); fields.add(f); fields.sort(new OrderedComparator()); connectFields(f, compositeField); if (compositeField.isInitConfigDone()) { f.init(); FormUtility.rebuildFieldGrid(compositeField); } }
/** * @return modifiable map of parameters (never <code>null</code>) * @throws AssertionError * if {@link #parse(String)} was not called before */ public Map<String, String> getParameters() { Assertions.assertTrue(m_parsed, "Not parsed yet"); return m_parameters; } }
Assertions.assertNotNull(form.getDisplayParent(), "Property 'displayParent' must not be null"); boolean view = (form.getDisplayHint() == IForm.DISPLAY_HINT_VIEW); boolean applicationLocked = m_formStore.containsApplicationModalDialogs() || m_messageBoxStore.containsApplicationModalMessageBoxes() || m_fileChooserStore.containsApplicationModalFileChoosers(); if (applicationLocked) { Assertions.fail(generateApplicationModalErrorMessage());
/** * 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 public Object marshall(final Object transferObject, final Map<String, String> context) { if (transferObject == null) { return null; } return assertInstance(transferObject, byte[].class, "bytes array expected [actual={}]", transferObject.getClass().getSimpleName()); }
/** * Same as {@link ClientRunContexts#copyCurrent()}, but less strict if not running in a {@link RunContext}. * * @param orElseEmpty * indicates whether to return an empty {@link RunContext} if not running in a context yet. * @throws AssertionException * if not running in a {@link RunContext}, and <i>orElseEmpty</i> is set to <code>false</code>. */ public static ClientRunContext copyCurrent(final boolean orElseEmpty) { if (RunContext.CURRENT.get() != null) { return BEANS.get(ClientRunContextFactory.class).copyCurrent(); } if (orElseEmpty) { return BEANS.get(ClientRunContextFactory.class).empty(); } return Assertions.fail("Not running in a RunContext. Use '{}.empty()' or {}.copyCurrent(true) instead.", ClientRunContexts.class.getSimpleName(), ClientRunContexts.class.getSimpleName()); }
@Override protected void attachModel() { super.attachModel(); Assertions.assertNull(m_formListener); m_formListener = new P_FormListener(); getModel().addFormListener(m_formListener); }
@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()); }
protected void assertWritable() { Assertions.assertTrue(m_writable, "This JSON response was already sent to the UI and is no longer writable!"); }
protected void handleModelColumnBackgroundEffectChanged(TableEvent event) { JSONObject jsonEvent = new JSONObject(); JSONArray eventParts = new JSONArray(); for (IColumn<?> c : event.getColumns()) { Assertions.assertInstance(c, INumberColumn.class, "ColumnBackgroundEffect is only supported on NumberColumns"); JSONObject eventPart = new JSONObject(); putProperty(eventPart, "columnId", getColumnId(c)); putProperty(eventPart, "backgroundEffect", ((INumberColumn) c).getBackgroundEffect()); eventParts.put(eventPart); } putProperty(jsonEvent, "eventParts", eventParts); addActionEvent(EVENT_COLUMN_BACKGROUND_EFFECT_CHANGED, jsonEvent); }
/** * Same as {@link ServerRunContexts#copyCurrent()}, but less strict if not running in a {@link RunContext} yet. * * @param orElseEmpty * indicates whether to return an empty {@link RunContext} if not running in a context yet. * @throws AssertionException * if not running in a {@link RunContext}, and <i>orElseEmpty</i> is set to <code>false</code>. */ public static ServerRunContext copyCurrent(final boolean orElseEmpty) { if (RunContext.CURRENT.get() != null) { return BEANS.get(ServerRunContextFactory.class).copyCurrent(); } if (orElseEmpty) { return BEANS.get(ServerRunContextFactory.class).empty(); } return Assertions.fail("Not running in a RunContext. Use '{}.empty()' or {}.copyCurrent(true) instead.", ServerRunContexts.class.getSimpleName(), ServerRunContexts.class.getSimpleName()); }
@PostConstruct public void start() { // ensure the poller starts only once. Assertions.assertNull(m_pollerFuture); if (BEANS.get(IServiceTunnel.class).isActive()) { m_pollerFuture = Jobs.schedule(new P_NotificationPoller(), Jobs.newInput() .withRunContext(ClientRunContexts.empty() .withSubject(BEANS.get(NotificationSubjectProperty.class).getValue()) .withUserAgent(UserAgents.createDefault()) .withSession(null, false)) .withName(ClientNotificationPoller.class.getSimpleName())); } else { LOG.debug("Starting without notifications due to no proxy service is available"); } }