001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2015-2016 ForgeRock AS. 016 */ 017package org.opends.guitools.controlpanel.datamodel; 018 019/** Class that describes the VLV sort order. */ 020public class VLVSortOrder 021{ 022 private String attributeName; 023 private boolean isAscending; 024 private int hashCode; 025 026 /** 027 * Constructor of the VLVSortOrder. 028 * @param attributeName the attribute name to be used to sort. 029 * @param isAscending whether the sorting is ascending or descending. 030 */ 031 public VLVSortOrder(String attributeName, boolean isAscending) 032 { 033 this.attributeName = attributeName; 034 this.isAscending = isAscending; 035 hashCode = ("vlvsortorder"+attributeName+isAscending).hashCode(); 036 } 037 038 /** 039 * Returns the name of the attribute. 040 * @return the name of the attribute. 041 */ 042 public String getAttributeName() 043 { 044 return attributeName; 045 } 046 047 /** 048 * Returns whether the sorting is ascending or descending. 049 * @return <CODE>true</CODE> if the sorting is ascending and 050 * <CODE>false</CODE> otherwise. 051 */ 052 public boolean isAscending() 053 { 054 return isAscending; 055 } 056 057 @Override 058 public int hashCode() 059 { 060 return hashCode; 061 } 062 063 @Override 064 public boolean equals(Object o) 065 { 066 if (o == this) { 067 return true; 068 } 069 if (o instanceof VLVSortOrder) 070 { 071 VLVSortOrder sortOrder = (VLVSortOrder)o; 072 return sortOrder.getAttributeName().equalsIgnoreCase(attributeName) 073 && sortOrder.isAscending() == isAscending; 074 } 075 return false; 076 } 077}