/*
 * Copyright 2011-2019 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.datastore.oplock;

import java.util.Date;

import com.b2international.snowowl.datastore.oplock.impl.DatastoreLockContext;
import com.b2international.snowowl.datastore.oplock.impl.DatastoreLockTarget;

/**
 * Contains all information about an operation lock which should be presented on an administrative interface. Sorts by date.
 *
 */
public class OperationLockInfo implements Comparable<OperationLockInfo> {

	private final int id;

	private final int level;

	private final Date creationDate;
	
	private final DatastoreLockTarget target;
	
	private final DatastoreLockContext context;

	public OperationLockInfo(final int id, final int lockLevel, final Date creationDate, final DatastoreLockTarget target, final DatastoreLockContext context) {
		this.id = id;
		this.level = lockLevel;
		this.creationDate = creationDate;
		this.target = target;
		this.context = context;
	}
	
	public int getId() {
		return id;
	}

	public int getLevel() {
		return level;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public DatastoreLockTarget getTarget() {
		return target;
	}
	
	public DatastoreLockContext getContext() {
		return context;
	}

	@Override
	public int compareTo(final OperationLockInfo otherInfo) {
		return creationDate.compareTo(otherInfo.creationDate);
	}
}
@@ -698,16 +698,42 @@
 il.Date;
+%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -882,16 +882,59 @@
 kTarget;
+%0Aimport com.google.common.base.MoreObjects;
 %0A%0A/**%0A *
@@ -1056,19 +1056,16 @@
 y date.%0A
- *%0A
  */%0Apubl
@@ -1944,24 +1944,24 @@
 therInfo) %7B%0A
-
 %09%09return cre
@@ -2008,9 +2008,756 @@
 te);%0A%09%7D%0A
+%09%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09return Objects.hash(id, level, target, context);%0A%09%7D%0A%09%0A%09@Override%0A%09public boolean equals(Object obj) %7B%0A%09%09if (this == obj) %7B%0A%09%09%09return true;%0A%09%09%7D%0A%0A%09%09if (!(obj instanceof OperationLockInfo)) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%0A%09%09final OperationLockInfo other = (OperationLockInfo) obj;%0A%09%09return Objects.equals(id, other.getId()) %0A%09%09%09%09&& Objects.equals(level, other.getLevel())%0A%09%09%09%09&& Objects.equals(target, other.getTarget())%0A%09%09%09%09&& Objects.equals(context, other.getContext());%0A%09%7D%0A%09%0A%09@Override%0A%09public String toString() %7B%0A%09%09return MoreObjects.toStringHelper(this)%0A%09%09%09%09.add(%22id%22, id)%0A%09%09%09%09.add(%22level%22, level)%0A%09%09%09%09.add(%22creationDate%22, creationDate)%0A%09%09%09%09.add(%22target%22, target)%0A%09%09%09%09.add(%22context%22, context)%0A%09%09%09%09.toString();%0A%09%7D%0A
 %7D

Add hashCode, equals, toString methods to OperationLockInfo