org.apache.wicket.util.lang.Objects Java Examples

The following examples show how to use org.apache.wicket.util.lang.Objects. 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: AbstractMetaPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <K extends AbstractMetaPanel<?, ?, ?>> K getMetaComponent(IMetaContext<?> context, final Object critery)
{
	if(context==null || critery==null) return null;
	else return (K)context.getContextComponent()
					.visitChildren(AbstractMetaPanel.class, new IVisitor<AbstractMetaPanel<?, ?, ?>, AbstractMetaPanel<?, ?, ?>>() {

						@Override
						public void component(
								AbstractMetaPanel<?, ?, ?> object,
								IVisit<AbstractMetaPanel<?, ?, ?>> visit) {
							if(Objects.isEqual(object.getPropertyObject(), critery)) visit.stop(object);
							else visit.dontGoDeeper();
						}
	});
}
 
Example #2
Source File: DefaultIssueChangeManager.java    From onedev with MIT License 5 votes vote down vote up
@Transactional
@Override
public void changeDescription(Issue issue, @Nullable String description) {
	String prevDescription = issue.getDescription();
	if (!Objects.equal(description, prevDescription)) {
		issue.setDescription(description);
		
		IssueChange change = new IssueChange();
		change.setIssue(issue);
		change.setDate(new Date());
		change.setUser(SecurityUtils.getUser());
		change.setData(new IssueDescriptionChangeData(prevDescription, issue.getDescription()));
		save(change);
	}
}
 
Example #3
Source File: DefaultIssueChangeManager.java    From onedev with MIT License 5 votes vote down vote up
@Transactional
@Override
public void changeMilestone(Issue issue, @Nullable Milestone milestone) {
	Milestone prevMilestone = issue.getMilestone();
	if (!Objects.equal(prevMilestone, milestone)) {
		issue.setMilestone(milestone);
		
		IssueChange change = new IssueChange();
		change.setIssue(issue);
		change.setDate(new Date());
		change.setUser(SecurityUtils.getUser());
		change.setData(new IssueMilestoneChangeData(prevMilestone, issue.getMilestone()));
		save(change);
	}
}
 
Example #4
Source File: FeatureStateModel.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof FeatureStateModel)) {
        return false;
    }
    FeatureStateModel that = (FeatureStateModel) obj;
    return Objects.equal(feature, that.feature);
}
 
Example #5
Source File: OSchemaHelper.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Set linked class to a current property
 * @param className class name to set as a linked class
 * @return this helper
 */
public OSchemaHelper linkedClass(String className)
{
	checkOProperty();
	OClass linkedToClass =  schema.getClass(className);
	if(linkedToClass==null) throw new IllegalArgumentException("Target OClass '"+className+"' to link to not found");
	if(!Objects.equal(linkedToClass, lastProperty.getLinkedClass()))
	{
		lastProperty.setLinkedClass(linkedToClass);
	}
	return this;
}
 
Example #6
Source File: TransactionRequestCycleListener.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Override
public void start(RequestCycle cycle) {
	OrientDbWebSession session = OrientDbWebSession.get();
	ODatabaseDocumentInternal db = session.getDatabase();
	//It's required to have ability to check security rights locally
	OSecurityUser oUser = session.getUser();
	OSecurityUser dbUser = db.getUser();
	if(oUser!=null && oUser.getDocument()!=null 
			&& oUser.getDocument().getIdentity()!=null 
			&& (!oUser.getDocument().getIdentity().isValid() || dbUser==null || !Objects.equal(dbUser.getName(), oUser.getName())))
	{
		db.setUser(db.getMetadata().getSecurity().getUser(oUser.getName()));
	}
	db.begin();
}
 
Example #7
Source File: UpdateOnDashboardDisplayModeChangeBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean match(Component component, ActionPerformedEvent<?> event,
		IEvent<?> wicketEvent) {
	if(component instanceof AbstractWidget && event.getCommand().isChangingDisplayMode()) {
		AbstractWidget<?> widget = (AbstractWidget<?>)component;
		return Objects.equal(widget.getDashboardPanel().getDashboardDocument(), event.getObject());
	} else return false;
}
 
Example #8
Source File: PlantUmlService.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public void describe(Writer writer, OProperty oProperty)
{
	PrintWriter out = toPrintWriter(writer);
	OType type = oProperty.getType();
	String min = oProperty.getMin();
	String max = oProperty.getMax();
	String range = null;
	
	if(min!=null || max!=null)
	{
		range = Objects.equal(min, max)?min:(min!=null?min:"0")+".."+(max!=null?max:"*");
	}
	else if(type.isMultiValue())
	{
		range = "*";
	}
	
	boolean isEmbedded = type.equals(OType.EMBEDDED) || type.equals(OType.EMBEDDEDLIST) 
			|| type.equals(OType.EMBEDDEDMAP) || type.equals(OType.EMBEDDEDSET);
	
	if(oProperty.getLinkedClass()!=null
			&& (isEmbedded || type.isLink()))
	{
		out.append(oProperty.getOwnerClass().getName());
		if(isEmbedded) out.append("\"1\" *-- ");
		else out.append(" -> ");
		if(range!=null) out.append('"').append(range).append("\" ");
		out.append(oProperty.getLinkedClass().getName());
		out.append(" : ").append(oProperty.getName());
	}
	else
	{
		out.append(oProperty.getOwnerClass().getName())
			.append(" : ")
			.append(oProperty.getName()).append(" : ").append(type.name());
	}
	out.println();
}
 
Example #9
Source File: EqualsDecorator.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
  String methodName = method.getName();
  if (methodName.equals("equals")) {
    if (args[0] instanceof IModel< ? >) {
      return Objects.equal(model.getObject(), ((IModel< ? >) args[0]).getObject());
    }
  } else if (methodName.equals("hashCode")) {
    Object val = model.getObject();
    return Objects.hashCode(val);
  } else if (methodName.equals("writeReplace")) {
    return new SerializableReplacement(model);
  }
  return method.invoke(model, args);
}
 
Example #10
Source File: EventManager.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public EventSource getEventSource(String id) throws EventSourceNotFoundException {

		for (EventSource source : calendar.getConfig().getEventSources()) {
			if (Objects.equal(id, source.getUuid())) {
				return source;
			}
		}
		throw new EventSourceNotFoundException("Event source with uuid: " + id + " not found");
	}
 
Example #11
Source File: UpdateOnActionPerformedEventBehavior.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
protected boolean match(Component component, ActionPerformedEvent<?> event, IEvent<?> wicketEvent) {
	return Objects.equal(component.getDefaultModelObject(), event.getObject());
}
 
Example #12
Source File: AbstractMetaPanel.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
protected Serializable getSignature(C critery)
{
	return Objects.hashCode(critery);
}
 
Example #13
Source File: AbstractModeMetaPanel.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
protected Serializable getSignature(C critery) {
	return Objects.hashCode(critery, getModeObject());
}