org.apache.wicket.util.lang.Args Java Examples
The following examples show how to use
org.apache.wicket.util.lang.Args.
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: WebSocketRequestHandler.java From onedev with MIT License | 6 votes |
@Override public void push(CharSequence message) { if (connection.isOpen()) { Args.notNull(message, "message"); try { connection.sendMessage(message.toString()); } catch (IOException iox) { LOG.error("An error occurred while pushing text message.", iox); } } else { LOG.warn("The websocket connection is already closed. Cannot push the text message '{}'", message); } }
Example #2
Source File: SimpleWebSocketConnectionRegistry.java From onedev with MIT License | 6 votes |
@Override public IWebSocketConnection getConnection(Application application, String sessionId, IKey key) { Args.notNull(application, "application"); Args.notNull(sessionId, "sessionId"); Args.notNull(key, "key"); IWebSocketConnection connection = null; ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY); if (connectionsBySession != null) { ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId); if (connectionsByPage != null) { connection = connectionsByPage.get(key); } } return connection; }
Example #3
Source File: SimpleWebSocketConnectionRegistry.java From onedev with MIT License | 6 votes |
@Override public Collection<IWebSocketConnection> getConnections(Application application, String sessionId) { Args.notNull(application, "application"); Args.notNull(sessionId, "sessionId"); Collection<IWebSocketConnection> connections = Collections.emptyList(); ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY); if (connectionsBySession != null) { ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId); if (connectionsByPage != null) { connections = connectionsByPage.values(); } } return connections; }
Example #4
Source File: ArtifactLinkParameterMappingEntry.java From artifact-listener with Apache License 2.0 | 6 votes |
@Override public void extract(PageParameters sourceParameters, ILinkParameterConversionService conversionService) throws LinkParameterExtractionException { Args.notNull(sourceParameters, "sourceParameters"); Args.notNull(conversionService, "conversionService"); String groupId = sourceParameters.get(GROUP_ID_PARAMETER).toString(); String artifactId = sourceParameters.get(ARTIFACT_ID_PARAMETER).toString(); Artifact artifact = null; if (groupId != null && artifactId != null) { ArtifactKey artifactKey = new ArtifactKey(groupId, artifactId); try { artifact = conversionService.convert(artifactKey, Artifact.class); } catch (ConversionException e) { throw new LinkParameterExtractionException(e); } } artifactModel.setObject(artifact); }
Example #5
Source File: SimpleWebSocketConnectionRegistry.java From onedev with MIT License | 6 votes |
/** * Returns a collection of currently active websockets. The connections might close at any time. * * @param application * The application * @return a collection of currently active websockets */ public Collection<IWebSocketConnection> getConnections(Application application) { Args.notNull(application, "application"); Collection<IWebSocketConnection> connections = new ArrayList<>(); ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY); if (connectionsBySession != null) { for (ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage : connectionsBySession.values()) { connections.addAll(connectionsByPage.values()); } } return connections; }
Example #6
Source File: WebSocketRequestHandler.java From onedev with MIT License | 6 votes |
@Override public void push(byte[] message, int offset, int length) { if (connection.isOpen()) { Args.notNull(message, "message"); try { connection.sendMessage(message, offset, length); } catch (IOException iox) { LOG.error("An error occurred while pushing binary message.", iox); } } else { LOG.warn("The websocket connection is already closed. Cannot push the binary message '{}'", message); } }
Example #7
Source File: WebSocketRequestHandler.java From onedev with MIT License | 6 votes |
@Override public void add(Component... components) { for (final Component component : components) { Args.notNull(component, "component"); if (component.getOutputMarkupId() == false) { throw new IllegalArgumentException( "cannot update component that does not have setOutputMarkupId property set to true. Component: " + component.toString()); } add(component, component.getMarkupId()); } }
Example #8
Source File: ArtifactLinkParameterMappingEntry.java From artifact-listener with Apache License 2.0 | 6 votes |
@Override public void inject(PageParameters targetParameters, ILinkParameterConversionService conversionService) throws LinkParameterInjectionException { Args.notNull(targetParameters, "targetParameters"); Args.notNull(conversionService, "conversionService"); Artifact artifact = artifactModel.getObject(); if (artifact != null) { if (artifact.getGroup() != null && artifact.getGroup().getGroupId() != null) { targetParameters.add(GROUP_ID_PARAMETER, artifact.getGroup().getGroupId()); } if (artifact.getArtifactId() != null) { targetParameters.add(ARTIFACT_ID_PARAMETER, artifact.getArtifactId()); } } }
Example #9
Source File: GridsterWidgetBehavior.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public final void bind(final Component hostComponent) { Args.notNull(hostComponent, "hostComponent"); if (component != null) { throw new IllegalStateException("this kind of handler cannot be attached to " + "multiple components; it is already attached to component " + component + ", but component " + hostComponent + " wants to be attached too"); } if(!(hostComponent instanceof AbstractWidget)) { throw new IllegalStateException("This behaviour can be attached only to "+AbstractWidget.class.getSimpleName()+ ", but this one: "+hostComponent.getClass().getName()); } component = (AbstractWidget<?>)hostComponent; }
Example #10
Source File: FormComponent.java From onedev with MIT License | 6 votes |
/** * Adds a validator to this form component * * @param validator * validator to be added * @return <code>this</code> for chaining * @throws IllegalArgumentException * if validator is null * @see IValidator */ @SuppressWarnings({ "rawtypes", "unchecked" }) public final FormComponent<T> add(final IValidator<? super T> validator) { Args.notNull(validator, "validator"); if (validator instanceof Behavior) { add((Behavior)validator); } else { add((Behavior)new ValidatorAdapter(validator)); } return this; }
Example #11
Source File: InfinitePagingDataTable.java From sakai with Educational Community License v2.0 | 6 votes |
public InfinitePagingDataTable(String id, final List<? extends IColumn<T, S>> columns, final InfiniteDataProvider<T> dataProvider, final long rowsPerPage) { super(id); Args.notEmpty(columns, "columns"); this.columns = columns; this.caption = new Caption("caption", getCaptionModel()); add(caption); body = newBodyContainer("body"); datagrid = newInfinitePagingDataGridView("rows", columns, dataProvider); datagrid.setItemsPerPage(rowsPerPage); body.add(datagrid); add(body); topToolbars = new ToolbarsContainer("topToolbars"); bottomToolbars = new ToolbarsContainer("bottomToolbars"); add(topToolbars); add(bottomToolbars); }
Example #12
Source File: Strings.java From onedev with MIT License | 6 votes |
/** * Calculates the length of string in bytes, uses specified <code>charset</code> if provided. * * @param string * @param charset * (optional) character set to use when converting string to bytes * @return length of string in bytes */ public static int lengthInBytes(final String string, final Charset charset) { Args.notNull(string, "string"); if (charset != null) { try { return string.getBytes(charset.name()).length; } catch (UnsupportedEncodingException e) { throw new RuntimeException( "StringResourceStream created with unsupported charset: " + charset.name()); } } else { return string.getBytes().length; } }
Example #13
Source File: Strings.java From onedev with MIT License | 6 votes |
/** * Return this value as en enum value. * * @param value * the value to convert to an enum value * @param enumClass * the enum type * @return an enum value */ public static <T extends Enum<T>> T toEnum(final CharSequence value, final Class<T> enumClass) { Args.notNull(enumClass, "enumClass"); Args.notNull(value, "value"); try { return Enum.valueOf(enumClass, value.toString()); } catch (Exception e) { throw new StringValueConversionException( String.format("Cannot convert '%s' to enum constant of type '%s'.", value, enumClass), e); } }
Example #14
Source File: SassResourceStream.java From webanno with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param sassStream * The resource stream that loads the Sass content. Only UrlResourceStream is * supported at the moment! * @param scopeClass * The name of the class used as a scope to resolve "package!" dependencies/imports */ public SassResourceStream(IResourceStream sassStream, String scopeClass) { Args.notNull(sassStream, "sassStream"); while (sassStream instanceof ResourceStreamWrapper) { ResourceStreamWrapper wrapper = (ResourceStreamWrapper) sassStream; try { sassStream = wrapper.getDelegate(); } catch (Exception x) { throw new WicketRuntimeException(x); } } if (!(sassStream instanceof UrlResourceStream)) { throw new IllegalArgumentException(String.format("%s can work only with %s", SassResourceStream.class.getSimpleName(), UrlResourceStream.class.getName())); } URL sassUrl = ((UrlResourceStream) sassStream).getURL(); SassCacheManager cacheManager = SassCacheManager.get(); this.sassSource = cacheManager.getSassContext(sassUrl, scopeClass); }
Example #15
Source File: InfinitePagingDataTable.java From sakai with Educational Community License v2.0 | 6 votes |
public InfinitePagingDataTable(String id, final List<? extends IColumn<T, S>> columns, final InfiniteDataProvider<T> dataProvider, final long rowsPerPage) { super(id); Args.notEmpty(columns, "columns"); this.columns = columns; this.caption = new Caption("caption", getCaptionModel()); add(caption); body = newBodyContainer("body"); datagrid = newInfinitePagingDataGridView("rows", columns, dataProvider); datagrid.setItemsPerPage(rowsPerPage); body.add(datagrid); add(body); topToolbars = new ToolbarsContainer("topToolbars"); bottomToolbars = new ToolbarsContainer("bottomToolbars"); add(topToolbars); add(bottomToolbars); }
Example #16
Source File: ExtendedWicketTester.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
/** * Process a component. A web page will be automatically created with the {@code pageMarkup} * provided. In case pageMarkup is null, the markup will be automatically created with * {@link #createFormPageMarkup(String, String)}. * <p> * <strong>Note</strong>: the instantiated component will have an auto-generated id. To * reach any of its children use their relative path to the component itself. For example * if the started component has a child a Link component with id "link" then after starting * the component you can click it with: <code>tester.clickLink("link")</code> * </p> * * @param <C> * the type of the component * * @param componentClass * the class of the component to be tested * @param inputType * the type of HTML input to be associated with the component to be tested * @param pageMarkup * the markup for the Page that will be automatically created. May be {@code null}. * @return The component processed */ @SuppressWarnings("deprecation") public final <C extends Component> C startComponentInForm(final Class<C> componentClass, final String inputType, final IMarkupFragment pageMarkup) { Args.notNull(componentClass, "componentClass"); // Create the component instance from the class C comp = null; try { Constructor<C> c = componentClass.getConstructor(String.class); comp = c.newInstance(ComponentInForm.ID); componentInForm = new ComponentInForm(); componentInForm.component = comp; componentInForm.isInstantiated = true; } catch (Exception e) { fail(String.format("Cannot instantiate component with type '%s' because of '%s'", componentClass.getName(), e.getMessage())); } // process the component return startComponentInForm(comp, inputType, pageMarkup); }
Example #17
Source File: WicketOrientDbFilterTesterScope.java From wicket-orientdb with Apache License 2.0 | 5 votes |
private void createEmbeddedFieldsForDocuments(List<ODocument> documents, List<ODocument> embedded) { Args.isTrue(documents.size() == embedded.size(), "documents.size() == embedded.size()"); for (int i = 0; i < documents.size(); i++) { ODocument document = documents.get(i); document.field(EMBEDDED_FIELD, embedded.get(i), OType.EMBEDDED); document.save(); } }
Example #18
Source File: WicketOrientDbFilterTesterScope.java From wicket-orientdb with Apache License 2.0 | 5 votes |
private void createMapDocsForDocuments(List<ODocument> documents, List<ODocument> mapDocs, boolean embedded) { Args.isTrue(documents.size() == mapDocs.size(), "documents.size() == mapDocs.size()"); for (int i = 0; i < documents.size(); i++) { ODocument document = documents.get(i); Map<String, ODocument> map = Maps.newHashMap(); map.put(MAP_KEYS.get(i), mapDocs.get(i)); if (embedded) { document.field(EMBEDDED_MAP_FIELD, map, OType.EMBEDDEDMAP); } else document.field(LINK_MAP_FIELD, map, OType.LINKMAP); document.save(); } }
Example #19
Source File: JsonUtil.java From Orienteer with Apache License 2.0 | 5 votes |
/** * Convert JSON string with array of classes to {@link List} * @param json JSON string which contains JSON array of OrientDB classes. * @return list of {@link OArchitectOClass} * @throws IllegalArgumentException if json is not JSON array */ public static List<OArchitectOClass> fromJSON(String json) { Args.isTrue(json.startsWith("["), "Input JSON string is not array! json: " + json); List<OArchitectOClass> classes = Lists.newArrayList(); JSONArray jsonArray = new JSONArray(json); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); classes.add(convertOClassFromJson(jsonObject)); } return classes; }
Example #20
Source File: SimpleVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
public SimpleVisualizer(String name, boolean extended, Class<? extends Component> viewComponentClass, Class<? extends Component> editComponentClass, Collection<OType> supportedTypes) { super(name, extended, supportedTypes); Args.notNull(name, "name"); Args.notNull(viewComponentClass, "viewComponentClass"); Args.notNull(editComponentClass, "editComponentClass"); Args.notNull(supportedTypes, "supportedTypes"); Args.notEmpty(supportedTypes, "supportedTypes"); this.viewComponentClass = viewComponentClass; this.editComponentClass = editComponentClass; }
Example #21
Source File: AbstractSimpleVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
public AbstractSimpleVisualizer(String name, boolean extended, Collection<OType> supportedTypes) { Args.notNull(name, "name"); Args.notNull(supportedTypes, "supportedTypes"); Args.notEmpty(supportedTypes, "supportedTypes"); this.name = name; this.extended = extended; this.supportedTypes = Collections.unmodifiableCollection(supportedTypes); }
Example #22
Source File: GenericTablePanel.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private GenericTablePanel(String id, List<? extends IColumn<K, String>> columns, ISortableDataProvider<K, String> provider, int rowsPerRange, boolean filtered) { super(id); Args.notNull(columns, "columns"); Args.notNull(provider, "provider"); setOutputMarkupPlaceholderTag(true); dataTable = new OrienteerDataTable<>("table", columns, provider, rowsPerRange); if (filtered) { FilterForm<OQueryModel<K>> filterForm = createFilterForm("form", (IFilterStateLocator<OQueryModel<K>>) provider); filterForm.setOutputMarkupPlaceholderTag(true); dataTable.addFilterForm(filterForm); filterForm.add(dataTable); AjaxFallbackButton button = new AjaxFallbackButton("submit", filterForm) {}; filterForm.setDefaultButton(button); filterForm.enableFocusTracking(button); filterForm.add(button); filterForm.add(dataTable); add(filterForm); } else { Form form = new Form("form"); form.add(dataTable); form.add(new AjaxFallbackButton("submit", form) {}.setVisible(false)); add(form); } add(new EmptyPanel("error").setVisible(false)); }
Example #23
Source File: OrienteerDataTable.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public void addFilterForm(FilterForm<OQueryModel<T>> filterForm) { Args.notNull(filterForm, "filterForm"); if (needAddFilterToolbar(filterForm)) { headersToolbar.setFilterForm(filterForm); } }
Example #24
Source File: WicketOrientDbFilterTesterScope.java From wicket-orientdb with Apache License 2.0 | 5 votes |
private void createLinksForDocuments(List<ODocument> documents, List<ODocument> links) { Args.isTrue(documents.size() == links.size(), "documents.size() == linkedDocs.size()"); for (int i = 0; i < documents.size(); i++) { ODocument document = documents.get(i); document.field(LINK_FIELD, links.get(i).getIdentity().toString(), OType.LINK); document.save(); } }
Example #25
Source File: OIndexPrototyper.java From wicket-orientdb with Apache License 2.0 | 5 votes |
public OIndexPrototyper(String className, List<String> fields) { Args.notEmpty(fields, "fields"); values.put(DEF_CLASS_NAME, className); values.put(DEF_FIELDS, fields); values.put(DEF_NULLS_IGNORED, true); if(fields!=null && fields.size()==1) { values.put(NAME, className+"."+fields.get(0)); } }
Example #26
Source File: DynamicPropertyValueModel.java From wicket-orientdb with Apache License 2.0 | 5 votes |
public DynamicPropertyValueModel(IModel<ODocument> docModel, IModel<OProperty> propertyModel, Class<? extends T> valueType) { Args.notNull(docModel, "documentModel"); this.docModel = docModel; this.propertyModel = propertyModel; this.valueType = valueType; }
Example #27
Source File: DocumentWrapperTransformer.java From wicket-orientdb with Apache License 2.0 | 5 votes |
/** * @param wrapperClass to wrap into */ public DocumentWrapperTransformer(Class<? extends T> wrapperClass) { Args.notNull(wrapperClass, "wrapperClass"); this.wrapperClass = wrapperClass; //To check that appropriate constructor exists getConstructor(); }
Example #28
Source File: DynamicPageParameters.java From artifact-listener with Apache License 2.0 | 5 votes |
public DynamicPageParameters add(String name, IModel<?> valueModel) { Args.notNull(name, "name"); Args.notNull(valueModel, "valueModel"); dynamicParametersMap.put(name, valueModel); return this; }
Example #29
Source File: FilterCriteriaManager.java From wicket-orientdb with Apache License 2.0 | 5 votes |
public FilterCriteriaManager(String field) { Args.notNull(field, "field"); this.field = field; filterCriterias = Maps.newHashMap(); and = true; }
Example #30
Source File: WicketOrientDbFilterTesterScope.java From wicket-orientdb with Apache License 2.0 | 5 votes |
private void createLinkListForDocument(List<ODocument> documents, List<List<ODocument>> linkList) { Args.isTrue(documents.size() == linkList.size(), "documents.size() == linkList.size()"); for (int i = 0; i < documents.size(); i++) { ODocument document = documents.get(i); document.field(LINK_LIST_FIELD, linkList.get(i), OType.LINKLIST); document.save(); } }