下面列出了org.apache.commons.lang.ObjectUtils#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean hasAccess(final PFUserDO user, final ToDoDO toDo, final OperationType operationType)
{
if (toDo == null) {
return true;
}
if (ObjectUtils.equals(user.getId(), toDo.getAssigneeId()) == true || ObjectUtils.equals(user.getId(), toDo.getReporterId()) == true) {
return true;
}
if (toDo.getGroup() != null && UserRights.getUserGroupCache().isUserMemberOfGroup(user.getId(), toDo.getGroupId()) == true) {
return true;
}
if (toDo.getTaskId() != null) {
return UserRights.getAccessChecker().hasPermission(user, toDo.getTaskId(), AccessType.TASKS, operationType, false);
} else {
return false;
}
}
/**
* Set the value of stateChangeToDate.
* @param v Value to assign to stateChangeToDate.
*/
public void setStateChangeToDate(String v)
{
if ( v != null && v.length() == 0 )
{
v = null;
}
if (!ObjectUtils.equals(v, this.stateChangeToDate))
{
modified = true;
this.stateChangeToDate = v;
}
}
private void validateClusterNameOfWorkflowInstance( long woinRefNum ){
WorkflowInstance woin = workflowInstanceService.find( woinRefNum );
String clusterName = config.getClusterName();
if( !ObjectUtils.equals( clusterName, woin.getClusterName() ) ){
throw new IllegalArgumentException( "The workflow instance " + woinRefNum + " is not executed by this cluster " + clusterName );
}
}
/**
* Checks if there exists any time sheet protection on the corresponding task or one of the ancestor tasks. If the times sheet is
* protected and the duration of this time sheet is modified, and AccessException will be thrown. <br/>
* Checks insert, update and delete operations. If an existing time sheet has to be modified, the check will only be done, if any
* modifications of the time stamps is done (e. g. descriptions of the task are allowed if the start and stop time is untouched).
* @param timesheet
* @param oldTimesheet (null for delete and insert)
* @param throwException If true and the time sheet protection is violated then an AccessException will be thrown.
* @return true, if no time sheet protection is violated or if the logged in user is member of the finance group.
* @see ProjectForgeGroup#FINANCE_GROUP
*/
public boolean checkTimesheetProtection(final PFUserDO user, final TimesheetDO timesheet, final TimesheetDO oldTimesheet,
final OperationType operationType, final boolean throwException)
{
if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.FINANCE_GROUP) == true
&& accessChecker.userEquals(user, timesheet.getUser()) == false) {
// Member of financial group are able to book foreign time sheets.
return true;
}
if (operationType == OperationType.UPDATE) {
if (timesheet.getStartTime().getTime() == oldTimesheet.getStartTime().getTime()
&& timesheet.getStopTime().getTime() == oldTimesheet.getStopTime().getTime()
&& ObjectUtils.equals(timesheet.getKost2Id(), oldTimesheet.getKost2Id()) == true) {
return true;
}
}
final TaskNode taskNode = taskTree.getTaskNodeById(timesheet.getTaskId());
Validate.notNull(taskNode);
final List<TaskNode> list = taskNode.getPathToRoot();
list.add(0, taskTree.getRootTaskNode());
for (final TaskNode node : list) {
final Date date = node.getTask().getProtectTimesheetsUntil();
if (date == null) {
continue;
}
final DateHolder dh = new DateHolder(date);
dh.setEndOfDay();
if (timesheet.getStartTime().before(dh.getDate()) == true) {
if (throwException == true) {
throw new AccessException("timesheet.error.timesheetProtectionVioloation", node.getTask().getTitle()
+ " (#"
+ node.getTaskId()
+ ")", DateHelper.formatIsoDate(dh.getDate()));
}
return false;
}
}
return true;
}
public boolean equals(Object o) {
if (o == null) return false;
if (!(o instanceof RuleExtensionBo)) return false;
RuleExtensionBo pred = (RuleExtensionBo) o;
return ObjectUtils.equals(ruleBaseValues.getRuleTemplate(), pred.getRuleBaseValues().getRuleTemplate()) &&
ObjectUtils.equals(ruleTemplateAttribute, pred.getRuleTemplateAttribute()) &&
CollectionUtils.collectionsEquivalent(extensionValues, pred.getExtensionValues());
}
@Override
public boolean equals(final Object o)
{
if (o instanceof TaskNode) {
final TaskNode other = (TaskNode) o;
return ObjectUtils.equals(this.getParentId(), other.getParentId()) == true
&& ObjectUtils.equals(this.getTask().getTitle(), other.getTask().getTitle()) == true;
}
return false;
}
/**
* Set the value of searchWords.
* @param v Value to assign to searchWords.
*/
public void setSearchWords(String v)
{
if (!ObjectUtils.equals(v, this.searchWords))
{
modified = true;
this.searchWords = v;
}
}
/**
* Set the value of sortPolarity.
* @param v Value to assign to sortPolarity.
*/
public void setSortPolarity(String v)
{
if (!ObjectUtils.equals(v, this.sortPolarity))
{
modified = true;
this.sortPolarity = v;
}
}
@Override
public boolean equals(final Object o)
{
if (o instanceof AuftragsPositionDO) {
final AuftragsPositionDO other = (AuftragsPositionDO) o;
if (ObjectUtils.equals(this.getNumber(), other.getNumber()) == false) {
return false;
}
if (ObjectUtils.equals(this.getAuftragId(), other.getAuftragId()) == false) {
return false;
}
return true;
}
return false;
}
@Override
public void buildSettingsReload(IProject p) {
IEditorInput editorInput = getEditorInput();
if (ObjectUtils.equals(p, CoreEditorUtils.getIProjectFrom(editorInput))) {
ParseTask parseTask = ParseTaskFactory.create(editorInput);
parseTask.setNeedModulaAst(true);
SymbolModelManager.instance().scheduleParse(parseTask, null);
}
}
@Override
public boolean equals(final Object o)
{
if (o instanceof AbstractRechnungsPositionDO) {
final AbstractRechnungsPositionDO other = (AbstractRechnungsPositionDO) o;
if (ObjectUtils.equals(this.getNumber(), other.getNumber()) == false) {
return false;
}
if (ObjectUtils.equals(this.getRechnungId(), other.getRechnungId()) == false) {
return false;
}
return true;
}
return false;
}
/**
* return true if id is equal, otherwise false;
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object o)
{
if (o instanceof Kost2ArtDO) {
final Kost2ArtDO other = (Kost2ArtDO) o;
return (ObjectUtils.equals(this.id, other.id));
}
return false;
}
/**
* Set the value of maxId.
* @param v Value to assign to maxId.
*/
public void setMaxId(String v)
{
if ( v != null && v.length() == 0 )
{
v = null;
}
if (!ObjectUtils.equals(v, this.maxId))
{
modified = true;
this.maxId = v;
}
}
public List<Share> getSharesForUser(User user) {
List<Share> result = new ArrayList<Share>();
for (Share share : getAllShares()) {
if (user.isAdminRole() || ObjectUtils.equals(user.getUsername(), share.getUsername())) {
result.add(share);
}
}
return result;
}
public boolean equals(Object o) {
if (o == null) return false;
if (!(o instanceof RuleExtensionValue)) return false;
RuleExtensionValue pred = (RuleExtensionValue) o;
return ObjectUtils.equals(key, pred.key) && ObjectUtils.equals(value, pred.value);
}
/**
* @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int)
*/
@SuppressWarnings("unchecked")
@Override
public Iterator<T> iterator(final long first, final long count)
{
if ((this.first != null && this.first != first) || (this.count != null && this.count != count)) {
this.completeList = null; // Force to load all elements from data-base (avoid lazy initialization exceptions).
}
final SortParam<String> sp = getSort();
if (ObjectUtils.equals(sortParam, sp) == false) {
// The sort parameters were changed, force reload from data-base:
reloadList();
}
this.first = first;
this.count = count;
if (idList == null) {
return null;
}
List<T> result;
int fromIndex = (int) first;
if (fromIndex < 0) {
fromIndex = 0;
}
int toIndex = (int) (first + count);
if (this.completeList != null) {
// The completeList is already load, don't need to load objects from data-base:
result = completeList;
if (toIndex > idList.size()) {
toIndex = idList.size();
}
result = new LinkedList<T>();
for (final T entry : completeList.subList(fromIndex, toIndex)) {
result.add(entry);
}
this.completeList = null; // Don't store the complete list on the server anymore.
return result.iterator();
} else {
if (toIndex > idList.size()) {
toIndex = idList.size();
}
final Object baseDao = listPage.getBaseDao();
if (baseDao instanceof BaseDao) {
final List<T> list = (List<T>) ((BaseDao< ? >) baseDao).internalLoad(idList.subList(fromIndex, toIndex));
sortList(list);
return list.iterator();
} else {
// Can't load objects from BaseDao, have to load complete list from scratch:
reloadList();
result = completeList;
if (toIndex > idList.size()) {
toIndex = idList.size();
}
return result.subList(fromIndex, toIndex).iterator();
}
}
}
@Override
public boolean isFulFilled() {
return !ObjectUtils.equals(prevValue, curValue);
}
public void setNewValue(Object newValue) {
this.newValue = newValue;
this.changed = !ObjectUtils.equals(this.originalValue, newValue);
}
@Override
public boolean equals(Object o) {
ArtifactKey other = (ArtifactKey) o;
return ObjectUtils.equals(type, other.type) && ObjectUtils.equals(classifier, other.classifier);
}
/**
* equals implementation
*
* @param object
* The object to compare
* @return true if equal, otherwise false
*/
@Override
public boolean equals( Object object )
{
// FIXME : use LuteceUser property instead of object.toString()
return ObjectUtils.equals( this.toString( ), ObjectUtils.toString( object ) );
}