Java tutorial
/* * Copyright (C) 2016 Giancarlo Frison <giancarlo@gfrison.com> * * Licensed under the UbiCrypt License, Version 1.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://github.com/gfrison/ubicrypt/LICENSE.md * 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 ubicrypt.core.dto; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; public class Key { private UbiFile.KeyType type = UbiFile.KeyType.aes; private byte[] bytes; public Key() { } public Key(byte[] bytes) { this.bytes = bytes; } public Key(byte[] bytes, UbiFile.KeyType type) { this.bytes = bytes; this.type = type; } public RemoteFile.KeyType getType() { return type; } public void setType(RemoteFile.KeyType type) { this.type = type; } public byte[] getBytes() { return bytes; } public void setBytes(byte[] bytes) { this.bytes = bytes; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Key key = (Key) o; return new EqualsBuilder().append(type, key.type).append(bytes, key.bytes).isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(17, 37).append(type).append(bytes).toHashCode(); } @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE).append("type", type).toString(); } }