package com.tinkerpop.blueprints.util.micro;

import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.Property;
import com.tinkerpop.blueprints.util.ElementHelper;

import java.util.Map;

/**
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public abstract class MicroElement implements Element {

    final Object id;
    final String label;

    public MicroElement(final Element element) {
        this.id = element.getId();
        this.label = element.getLabel();
    }

    public Object getId() {
        return this.id;
    }

    public String getLabel() {
        return this.label;
    }

    public void setProperty(final String key, final Object value) {
        throw new UnsupportedOperationException();
    }

    public <V> Property<V> getProperty(final String key) {
        throw new UnsupportedOperationException();
    }

    public Map<String, Property> getProperties() {
        throw new UnsupportedOperationException();
    }

    public void remove() {
        throw new UnsupportedOperationException();
    }

    public int hashCode() {
        return this.id.hashCode();
    }

    public boolean equals(final Object object) {
        return ElementHelper.areEqual(this, object);
    }
}

package com.tinkerpop.blueprints.util.micro;

import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.Property;
import com.tinkerpop.blueprints.util.ElementHelper;

import java.util.Map;
import java.util.Objects;

/**
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public abstract class MicroElement implements Element {

    final Object id;
    final String label;

    public MicroElement(final Element element) {
        Objects.requireNonNull(element);
        this.id = element.getId();
        this.label = element.getLabel();
    }

    public Object getId() {
        return this.id;
    }

    public String getLabel() {
        return this.label;
    }

    public void setProperty(final String key, final Object value) {
        throw new UnsupportedOperationException();
    }

    public <V> Property<V> getProperty(final String key) {
        throw new UnsupportedOperationException();
    }

    public Map<String, Property> getProperties() {
        throw new UnsupportedOperationException();
    }

    public void remove() {
        throw new UnsupportedOperationException();
    }

    public int hashCode() {
        return this.id.hashCode();
    }

    public boolean equals(final Object object) {
        return ElementHelper.areEqual(this, object);
    }
}

Check non null for element in MicroElement.