| /** |
| * Copyright (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany |
| * |
| * This source was created by OSBP Softwarefactory Wizard! |
| * |
| * OSBP is (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany |
| * |
| * ================================================================ |
| * |
| * @file $HeadURL$ |
| * @version $Revision$ |
| * @date $Date$ |
| * @author $Author$ |
| */ |
| package org.osbp.mysmartshop.entities; |
| |
| import java.util.function.Consumer; |
| import java.util.function.Supplier; |
| |
| import javax.persistence.Id; |
| import javax.persistence.MappedSuperclass; |
| import javax.persistence.Transient; |
| |
| import org.eclipse.osbp.dsl.common.datatypes.IEntity; |
| import org.eclipse.osbp.runtime.common.annotations.Dispose; |
| |
| @MappedSuperclass |
| @SuppressWarnings("all") |
| public class BaseUUID implements IEntity { |
| @Transient |
| @Dispose |
| private boolean disposed; |
| |
| @Id |
| private String id = java.util.UUID.randomUUID().toString(); |
| |
| /** |
| * INTERNAL: |
| * |
| * @param selector |
| * @return |
| */ |
| public Consumer<?> internalGetRawConsumer(String selector) { |
| switch (selector) { |
| case "setId": |
| return (Consumer<String>) this::setId; |
| } |
| throw new IllegalArgumentException("Not a valid consumer: " + selector); |
| } |
| |
| /** |
| * INTERNAL: |
| * |
| * @param selector |
| * @return |
| */ |
| public Supplier<?> internalGetRawSupplier(String selector) { |
| switch (selector) { |
| case "getId": |
| return (Supplier<String>) this::getId; |
| } |
| throw new IllegalArgumentException("Not a valid supplier: " + selector); |
| } |
| |
| /** |
| * @return true, if the object is disposed. Disposed means, that it is |
| * prepared for garbage collection and may not be used anymore. |
| * Accessing objects that are already disposed will cause runtime |
| * exceptions. |
| * |
| */ |
| @Dispose |
| public boolean isDisposed() { |
| return this.disposed; |
| } |
| |
| /** |
| * Checks whether the object is disposed. |
| * |
| * @throws RuntimeException |
| * if the object is disposed. |
| */ |
| private void checkDisposed() { |
| if (isDisposed()) { |
| throw new RuntimeException("Object already disposed: " + this); |
| } |
| } |
| |
| /** |
| * Calling dispose will destroy that instance. The internal state will be |
| * set to 'disposed' and methods of that object must not be used anymore. |
| * Each call will result in runtime exceptions.<br> |
| * If this object keeps composition containments, these will be disposed |
| * too. So the whole composition containment tree will be disposed on |
| * calling this method. |
| */ |
| @Dispose |
| public void dispose() { |
| if (isDisposed()) { |
| return; |
| } |
| disposed = true; |
| } |
| |
| /** |
| * @return Returns the id property or <code>null</code> if not present. |
| */ |
| public String getId() { |
| checkDisposed(); |
| return this.id; |
| } |
| |
| /** |
| * Sets the id property to this instance. |
| */ |
| public void setId(final String id) { |
| checkDisposed(); |
| this.id = id; |
| } |
| |
| @Override |
| public boolean equals(final Object obj) { |
| if (this == obj) |
| return true; |
| if (obj == null) |
| return false; |
| if (getClass() != obj.getClass()) |
| return false; |
| BaseUUID other = (BaseUUID) obj; |
| if (this.id == null) { |
| if (other.id != null) |
| return false; |
| } else if (!this.id.equals(other.id)) |
| return false; |
| return true; |
| } |
| |
| @Override |
| public int hashCode() { |
| int prime = 31; |
| int result = 1; |
| result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); |
| return result; |
| } |
| } |