code
stringlengths
73
34.1k
label
stringclasses
1 value
public static <T, P> AsyncCallback<T> map (AsyncCallback<P> target, final Function<T, P> f) { return new ChainedCallback<T, P>(target) { @Override public void onSuccess (T result) { forwardSuccess(f.apply(result)); } }; }
java
public static <T> AsyncCallback<T> before (AsyncCallback<T> target, final Function<T, Void> preOp) { return new ChainedCallback<T, T>(target) { @Override public void onSuccess (T result) { preOp.apply(result); forward...
java
public static <T> AsyncCallback<T> disabler (AsyncCallback<T> callback, final HasEnabled... disablees) { for (HasEnabled widget : disablees) { widget.setEnabled(false); } return new ChainedCallback<T, T>(callback) { @Ov...
java
@SuppressWarnings("unchecked") protected final MODEL_ID tryConvertId(Object id) { try { return (MODEL_ID) getModelBeanDescriptor().convertId(id); } catch (Exception e) { throw new UnprocessableEntityException(Messages.get("info.query.id.unprocessable.entity"), e); } ...
java
protected boolean deleteMultipleModel(Set<MODEL_ID> idCollection, boolean permanent) throws Exception { if (permanent) { server.deleteAllPermanent(modelType, idCollection); } else { server.deleteAll(modelType, idCollection); } return permanent; }
java
protected boolean deleteModel(MODEL_ID id, boolean permanent) throws Exception { if (permanent) { server.deletePermanent(modelType, id); } else { server.delete(modelType, id); } return permanent; }
java
public Response findByIds(@NotNull @PathParam("ids") URI_ID id, @NotNull @PathParam("ids") final PathSegment ids, @QueryParam("include_deleted") final boolean includeDeleted) throws Exception { final Query<MODEL> query = server.find(modelType); ...
java
public Response fetchHistoryAsOf(@PathParam("id") URI_ID id, @PathParam("asof") final Timestamp asOf) throws Exception { final MODEL_ID mId = tryConvertId(id); matchedFetchHistoryAsOf(mId, asOf); final Query<MODEL> query = server.find(modelType); def...
java
public static String parseQueryFields(UriInfo uriInfo) { List<String> selectables = uriInfo.getQueryParameters() .get(EntityFieldsScopeResolver.FIELDS_PARAM_NAME); StringBuilder builder = new StringBuilder(); if (selectables != null) { for (int i = 0; i < selectables....
java
public void setSelectedValue (E value) { String valstr = value.toString(); for (int ii = 0; ii < getItemCount(); ii++) { if (getValue(ii).equals(valstr)) { setSelectedIndex(ii); break; } } }
java
public E getSelectedEnum () { int selidx = getSelectedIndex(); return (selidx < 0) ? null : Enum.valueOf(_eclass, getValue(selidx)); }
java
public boolean hasPath(String path) { Props props = pathMap.get(path); return props != null && !props.isEmpty(); }
java
public Set<String> getProperties(String path) { Props props = pathMap.get(path); return props == null ? null : props.getProperties(); }
java
public void put(String path, Set<String> properties) { pathMap.put(path, new Props(this, null, path, properties)); }
java
public void each(Each<Props> each) { for (Map.Entry<String, Props> entry : pathMap.entrySet()) { Props props = entry.getValue(); each.execute(props); } }
java
public void finished() { final ScheduledFuture<?> scheduled = nextCall.getAndSet(null); if (scheduled != null) { scheduled.cancel(true); } }
java
public static void bindEnabled (Value<Boolean> value, final FocusWidget... targets) { value.addListenerAndTrigger(new Value.Listener<Boolean>() { public void valueChanged (Boolean enabled) { for (FocusWidget target : targets) { target.setEnabled(enabled); ...
java
public static void bindVisible (Value<Boolean> value, final Widget... targets) { value.addListenerAndTrigger(new Value.Listener<Boolean>() { public void valueChanged (Boolean visible) { for (Widget target : targets) { target.setVisible(visible); ...
java
public static <T extends HasMouseOverHandlers & HasMouseOutHandlers> void bindHovered ( final Value<Boolean> value, T... targets) { HoverHandler handler = new HoverHandler(value); for (T target : targets) { target.addMouseOverHandler(handler); target.addMouseOutHandle...
java
public static void bindLabel (final Value<String> value, final HasText target) { value.addListenerAndTrigger(new Value.Listener<String>() { public void valueChanged (String value) { // avoid updating the target if the value is already the same; in the case where /...
java
public static ClickHandler makeToggler (final Value<Boolean> value) { Preconditions.checkNotNull(value, "value"); return new ClickHandler() { public void onClick (ClickEvent event) { value.update(!value.get()); } }; }
java
public static void bindStateStyle (Value<Boolean> value, final String onStyle, final String offStyle, final Widget... targets) { value.addListenerAndTrigger(new Value.Listener<Boolean>() { public void valueChanged (Boolean value) { String ad...
java
private List<MigrationInfo> resolved(MigrationInfo[] migrationInfos) { if (migrationInfos.length == 0) throw new NotFoundException(); List<MigrationInfo> resolvedMigrations = Lists.newArrayList(); for (MigrationInfo migrationInfo : migrationInfos) { if (migrationInfo.getS...
java
private List<MigrationInfo> failed(MigrationInfo[] migrationInfos) { if (migrationInfos.length == 0) throw new NotFoundException(); List<MigrationInfo> failedMigrations = Lists.newArrayList(); for (MigrationInfo migrationInfo : migrationInfos) { if (migrationInfo.getState...
java
private List<MigrationInfo> future(MigrationInfo[] migrationInfos) { if (migrationInfos.length == 0) throw new NotFoundException(); List<MigrationInfo> futureMigrations = Lists.newArrayList(); for (MigrationInfo migrationInfo : migrationInfos) { if ((migrationInfo.getStat...
java
public static void updateDisks(Document domainXml, List<StorageVol> volumes) throws LibvirtException { XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> diskExpr = xpf.compile(XPATH_DISK, Filters.element()); XPathExpression<Attribute> fileExpr = xpf.compile(XPATH_DISK_FILE, Fi...
java
public static List<Disk> getDisks(Connect connect, Document domainXml) { try { List<Disk> ret = new ArrayList<>(); XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> diskExpr = xpf.compile(XPATH_DISK, Filters.element()); XPathExpression<Attribute...
java
public static GroupMapping mapping(Map.Entry<String, Mapping<?>>... fields) { return new GroupMapping(Arrays.asList(fields)); }
java
public static Map.Entry<String, Mapping<?>> field(String name, Mapping<?> mapping) { return FrameworkUtils.entry(name, mapping); }
java
public boolean removeCustomer(Long customerId) { Customer customer = getCustomer(customerId); if(customer != null){ customerRepository.delete(customer); return true; } return false; }
java
public static void parkAndSerialize(final FiberWriter writer) { try { Fiber.parkAndSerialize(writer); } catch (SuspendExecution e) { throw RuntimeSuspendExecution.of(e); } }
java
public static <V> Fiber<V> unparkSerialized(byte[] serFiber, FiberScheduler scheduler) { return Fiber.unparkSerialized(serFiber, scheduler); }
java
public static <V> V runInFiber(FiberScheduler scheduler, SuspendableCallable<V> target) throws ExecutionException, InterruptedException { return FiberUtil.runInFiber(scheduler, target); }
java
public static void runInFiber(FiberScheduler scheduler, SuspendableRunnable target) throws ExecutionException, InterruptedException { FiberUtil.runInFiber(scheduler, target); }
java
@RequestMapping(path = "", method = RequestMethod.GET) public Page<Order> getOrder(Pageable pageable) { return orderService.getOrders(pageable); }
java
@RequestMapping(path = "/{orderId}", method = {RequestMethod.GET, RequestMethod.POST}) public ResponseEntity<Order> getOrder(@PathVariable("orderId") Long orderId) { Order order = orderService.getOrder(orderId); if(order != null){ return new ResponseEntity(order, HttpStatus.OK); ...
java
@RequestMapping(path="/{orderId}/status", method = RequestMethod.PUT) public ResponseEntity<Order> updateStatus(@PathVariable("orderId") Long orderId, @RequestParam("status") OrderStatus status){ Order order = orderService.updateStatus(orderId, status); if(order != null){ return new Resp...
java
public boolean vmExists(final String vmOrUuid) { String[] lines = execute("list", "vms").split("\\s"); for (String line : lines) { if (line.endsWith("{" + vmOrUuid + "}") || line.startsWith("\"" + vmOrUuid + "\"")) return true; } return false; }
java
public void loadSnapshot(String vm, String snapshotUuid) { if (!EnumSet.of(POWEROFF, SAVED).contains(vmState(vm))) { powerOff(vm); } execute("snapshot", vm, "restore", snapshotUuid); start(vm); }
java
public String execute(String... command) { return commandProcessor.run(aCommand("VBoxManage").withArguments(command)).getOutput(); }
java
public void setExtraData(String vm, String k, String v) { execute("setextradata", vm, k, v); }
java
public void update (T value) { // store our new current value _value = value; // notify our listeners; we snapshot our listeners before iterating to avoid problems if // listeners add or remove themselves while we're dispatching this notification for (Listener<T> listener : ...
java
public void displayPage (final int page, boolean forceRefresh) { if (_page == page && !forceRefresh) { return; // NOOP! } // Display the now loading widget, if necessary. configureLoadingNavi(_controls, 0, _infoCol); _page = Math.max(page, 0); final boo...
java
public void removeItem (T item) { if (_model == null) { return; // if we have no model, stop here } // remove the item from our data model _model.removeItem(item); // force a relayout of this page displayPage(_page, true); }
java
protected void configureNavi (FlexTable controls, int row, int col, int start, int limit, int total) { HorizontalPanel panel = new HorizontalPanel(); panel.add(new Label("Page:")); // TODO: i18n // determine which pages we want to show int page = 1+...
java
protected void reportFailure (Throwable caught) { java.util.logging.Logger.getLogger("PagedWidget").warning("Failure to page: " + caught); }
java
public void onKeyPress (KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ESCAPE) { _onEscape.onClick(null); } }
java
private static List<MediaType> getResourceMethodProducibleTypes(final ExtendedUriInfo extendedUriInfo) { if (extendedUriInfo.getMatchedResourceMethod() != null && !extendedUriInfo.getMatchedResourceMethod().getProducedTypes().isEmpty()) { return extendedUriInfo.getMatchedResourceMeth...
java
public static Charset getTemplateOutputEncoding(Configuration configuration, String suffix) { final String enc = PropertiesHelper.getValue(configuration.getProperties(), MvcFeature.ENCODING + suffix, String.class, null); if (enc == null) { return DEFAULT_ENCODING; } e...
java
public static Map<String, String> getMacs(Document domainXml) { Map<String, String> macs = new HashMap<>(); XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> interfaces = xpf.compile("/domain/devices/interface", Filters.element()); for (Element iface : interfaces.evalu...
java
public static <V> V runWithMock(EbeanServer mock, Callable<V> test) throws Exception { return start(mock).run(test); }
java
public <V> V run(Callable<V> testCallable) throws Exception { try { beforeRun(); return testCallable.call(); } finally { afterRun(); restoreOriginal(); } }
java
public void restoreOriginal() { if (original == null) { throw new IllegalStateException("Original EbeanServer instance is null"); } if (original.getName() == null) { throw new IllegalStateException("Original EbeanServer name is null"); } // restore the original EbeanServer back Ebea...
java
protected static Integer getSingleIntegerParam(List<String> list) { String s = getSingleParam(list); if (s != null) { try { return Integer.valueOf(s); } catch (NumberFormatException e) { return null; } } return null; ...
java
protected static String getSingleParam(List<String> list) { if (list != null && list.size() == 1) { return list.get(0); } return null; }
java
public static <T extends FocusWidget & HasText> String requireNonEmpty (T widget, String error) { String text = widget.getText().trim(); if (text.length() == 0) { Popups.errorBelow(error, widget); widget.setFocus(true); throw new InputException(); } ...
java
public static void tint(View view, Tint tint) { final ColorStateList color = tint.getColor(view.getContext()); if (view instanceof ImageView) { tint(((ImageView) view).getDrawable(), color); } else if (view instanceof TextView) { TextView text = (TextView) view; ...
java
public DomainWrapper cloneWithBackingStore(String cloneName, List<Filesystem> mappings) { logger.info("Creating clone from {}", getName()); try { // duplicate definition of base Document cloneXmlDocument = domainXml.clone(); setDomainName(cloneXmlDocument, cloneName)...
java
public static <T> SimpleDataModel<T> newModel (List<T> items) { return new SimpleDataModel<T>(items); }
java
public SimpleDataModel<T> filter (Predicate<T> pred) { // if (Predicates.alwaysTrue().equals(pred)) { // return this; // optimization // } List<T> items = new ArrayList<T>(); for (T item : _items) { if (pred.apply(item)) { items.add(item); ...
java
public void addItem (int index, T item) { if (_items == null) { return; } _items.add(index, item); }
java
public void updateItem (T item) { if (_items == null) { return; } int idx = _items.indexOf(item); if (idx == -1) { _items.add(0, item); } else { _items.set(idx, item); } }
java
public T findItem (Predicate<T> p) { if (_items == null) { return null; } for (T item : _items) { if (p.apply(item)) { return item; } } return null; }
java
@SuppressWarnings("unchecked") public <M extends T> M byId(ID id) { return (M) server().find(getModelType(), id); }
java
@SuppressWarnings("unchecked") public <M extends T> M ref(ID id) { return (M) server().getReference(getModelType(), id); }
java
@SuppressWarnings("unchecked") public <M extends T> Map<?, M> findMap() { return (Map<?, M>) query().findMap(); }
java
@SuppressWarnings("unchecked") public <M extends T> Set<M> findSet() { return (Set<M>) query().findSet(); }
java
public static SimplePanel newSimplePanel (String styleName, Widget widget) { SimplePanel panel = new SimplePanel(); if (widget != null) { panel.setWidget(widget); } return setStyleNames(panel, styleName); }
java
public static FlowPanel newFlowPanel (String styleName, Widget... contents) { FlowPanel panel = new FlowPanel(); for (Widget child : contents) { if (child != null) { panel.add(child); } } return setStyleNames(panel, styleName); }
java
public static ScrollPanel newScrollPanelX (Widget contents, int maxWidth) { ScrollPanel panel = new ScrollPanel(contents); DOM.setStyleAttribute(panel.getElement(), "maxWidth", maxWidth + "px"); return panel; }
java
public static ScrollPanel newScrollPanelY (Widget contents, int maxHeight) { ScrollPanel panel = new ScrollPanel(contents); DOM.setStyleAttribute(panel.getElement(), "maxHeight", maxHeight + "px"); return panel; }
java
public static HorizontalPanel newRow (String styleName, Widget... contents) { return newRow(HasAlignment.ALIGN_MIDDLE, styleName, contents); }
java
public static HorizontalPanel newRow (HasAlignment.VerticalAlignmentConstant valign, String styleName, Widget... contents) { HorizontalPanel row = new HorizontalPanel(); row.setVerticalAlignment(valign); if (styleName != null) { row.setSt...
java
public static Label newLabel (String text, String... styles) { return setStyleNames(new Label(text), styles); }
java
public static InlineLabel newInlineLabel (String text, String... styles) { return setStyleNames(new InlineLabel(text), styles); }
java
public static Label newActionLabel (String text, ClickHandler onClick) { return newActionLabel(text, null, onClick); }
java
public static Label newActionLabel (String text, String style, ClickHandler onClick) { return makeActionLabel(newLabel(text, style), onClick); }
java
public static Label makeActionLabel (Label label, ClickHandler onClick) { return makeActionable(label, onClick, null); }
java
public static <T extends Widget & HasClickHandlers> T makeActionable ( final T target, final ClickHandler onClick, Value<Boolean> enabled) { if (onClick != null) { if (enabled != null) { enabled.addListenerAndTrigger(new Value.Listener<Boolean>() { pub...
java
public static HTML newHTML (String text, String... styles) { return setStyleNames(new HTML(text), styles); }
java
public static Image newImage (String path, String... styles) { return setStyleNames(new Image(path), styles); }
java
public static Image makeActionImage (Image image, String tip, ClickHandler onClick) { if (tip != null) { image.setTitle(tip); } return makeActionable(image, onClick, null); }
java
public static TextBox newTextBox (String text, int maxLength, int visibleLength) { return initTextBox(new TextBox(), text, maxLength, visibleLength); }
java
public static String getText (TextBoxBase box, String defaultAsBlank) { String s = box.getText().trim(); return s.equals(defaultAsBlank) ? "" : s; }
java
public static TextBox initTextBox (TextBox box, String text, int maxLength, int visibleLength) { if (text != null) { box.setText(text); } box.setMaxLength(maxLength > 0 ? maxLength : 255); if (visibleLength > 0) { box.setVisibleLength(visibleLength); }...
java
public static TextArea newTextArea (String text, int width, int height) { TextArea area = new TextArea(); if (text != null) { area.setText(text); } if (width > 0) { area.setCharacterWidth(width); } if (height > 0) { area.setVisibleL...
java
public static LimitedTextArea newTextArea (String text, int width, int height, int maxLength) { LimitedTextArea area = new LimitedTextArea(maxLength, width, height); if (text != null) { area.setText(text); } return area; }
java
public static PushButton newImageButton (String style, ClickHandler onClick) { PushButton button = new PushButton(); maybeAddClickHandler(button, onClick); return setStyleNames(button, style, "actionLabel"); }
java
public static <T extends Widget> T setStyleNames (T widget, String... styles) { int idx = 0; for (String style : styles) { if (style == null) { continue; } if (idx++ == 0) { widget.setStyleName(style); } else { ...
java
private ConcurrentManaged<T> newManaged() { return ConcurrentManaged.newManaged(async, caller, managedOptions, setup, teardown); }
java
public static PreProcessor changePrefix(String from, String to) { return mkPreProcessorWithMeta((prefix, data, options) -> { logger.debug("changing prefix at '{}' from '{}' to '{}'", prefix, from, to); return data.entrySet().stream() .map(e -> { ...
java
public static Command delay (final Command command, final int delay) { return (command == null) ? null : new Command() { public void execute () { new Timer() { @Override public void run () { command.execute(); } ...
java
private String escapeSockJsSpecialChars(char[] characters) { StringBuilder result = new StringBuilder(); for (char c : characters) { if (isSockJsSpecialChar(c)) { result.append('\\').append('u'); String hex = Integer.toHexString(c).toLowerCase(); ...
java
private boolean isSockJsSpecialChar(char ch) { return ch <= '\u001F' || ch >= '\u200C' && ch <= '\u200F' || ch >= '\u2028' && ch <= '\u202F' || ch >= '\u2060' && ch <= '\u206F' || ch >= '\uFFF0' || ch >= '\uD800' && ch <= '\uDFFF'; ...
java
@MainThread private void scheduleActiveStatusesUpdates(EventTarget target, EventStatus status) { for (Event event : activeEvents) { for (EventMethod method : target.methods) { if (event.getKey().equals(method.eventKey) && method.type == EventMethod.Type.ST...
java
@MainThread private void scheduleStatusUpdates(Event event, EventStatus status) { for (EventTarget target : targets) { for (EventMethod method : target.methods) { if (event.getKey().equals(method.eventKey) && method.type == EventMethod.Type.STATUS) { ...
java
@MainThread private void scheduleSubscribersInvocation(Event event) { for (EventTarget target : targets) { for (EventMethod method : target.methods) { if (event.getKey().equals(method.eventKey) && method.type == EventMethod.Type.SUBSCRIBE) { ...
java
@MainThread private void scheduleResultCallbacks(Event event, EventResult result) { for (EventTarget target : targets) { for (EventMethod method : target.methods) { if (event.getKey().equals(method.eventKey) && method.type == EventMethod.Type.RESULT) { ...
java
@MainThread private void scheduleFailureCallbacks(Event event, EventFailure failure) { // Sending failure callback for explicit handlers of given event for (EventTarget target : targets) { for (EventMethod method : target.methods) { if (event.getKey().equals(method.eventK...
java
@MainThread private void handleRegistration(Object targetObj) { if (targetObj == null) { throw new NullPointerException("Target cannot be null"); } for (EventTarget target : targets) { if (target.targetObj == targetObj) { Utils.logE(targetObj, "Alread...
java