<commit_before>/*
 * Copyright (c) 2015 Intel Corporation  All rights reserved.
 * Copyright (c) 2015 <NAME>  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.neutron.spi;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public abstract class NeutronObject<T extends NeutronObject<T>> extends NeutronID implements INeutronObject<T> {
    // T extends NeutronObject as 0th type argument. Used by extractFields()
    private static final int NEUTRON_OBJECT_CLASS_TYPE_INDEX = 0;

    private static final Logger LOG = LoggerFactory.getLogger(NeutronFirewallRule.class);

    private static final long serialVersionUID = 1L;

    @XmlElement(name = "tenant_id")
    String tenantID;

    @XmlElement(name = "project_id")
    String projectID;

    @XmlElement(name = "revision_number")
    Long revisionNumber;

    public NeutronObject() {
    }

    @Override
    public String getTenantID() {
        if (tenantID != null && tenantID.isEmpty()) {
            // Bug 4775 - Treat empty string tenantId as null, so no attempt is made
            //            to turn it into a uuid.
            return null;
        }
        return tenantID;
    }

    @Override
    public void setTenantID(String tenantID) {
        this.tenantID = tenantID;
    }

    @Override
    @XmlTransient
    public void setTenantID(Uuid tenantID) {
        this.tenantID = tenantID.getValue().replace("-", "");
    }

    @Override
    public String toString() {
        return "NeutronObject [id=" + uuid + ", tenantID=" + tenantID + "]";
    }

    @Override
    public void setProjectID(String projectID) {
        this.projectID = projectID;
    }

    @Override
    public String getProjectID() {
        return this.projectID;
    }

    @Override
    public Long getRevisionNumber() {
        return revisionNumber;
    }<commit_msg>fix JAXB usage/design bug in NeutronObject re. null tenant_id<commit_after>/*
 * Copyright (c) 2015 Intel Corporation  All rights reserved.
 * Copyright (c) 2015 <NAME>  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.neutron.spi;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public abstract class NeutronObject<T extends NeutronObject<T>> extends NeutronID implements INeutronObject<T> {
    // T extends NeutronObject as 0th type argument. Used by extractFields()
    private static final int NEUTRON_OBJECT_CLASS_TYPE_INDEX = 0;

    private static final Logger LOG = LoggerFactory.getLogger(NeutronFirewallRule.class);

    private static final long serialVersionUID = 1L;

    String tenantID;

    @XmlElement(name = "project_id")
    String projectID;

    @XmlElement(name = "revision_number")
    Long revisionNumber;

    public NeutronObject() {
    }

    @Override
    @XmlElement(name = "tenant_id")
    public String getTenantID() {
        if (tenantID != null && tenantID.isEmpty()) {
            // Bug 4775 - Treat empty string tenantId as null, so no attempt is made
            //            to turn it into a uuid.
            return null;
        }
        return tenantID;
    }

    @Override
    @XmlElement(name = "tenant_id")
    public void setTenantID(String tenantID) {
        this.tenantID = tenantID;
    }

    @Override
    @XmlTransient
    public void setTenantID(Uuid tenantID) {
        this.tenantID = tenantID.getValue().replace("-", "");
    }

    @Override
    public String toString() {
        return "NeutronObject [id=" + uuid + ", tenantID=" + tenantID + "]";
    }

    @Override
    public void setProjectID(String projectID) {
        this.projectID = projectID;
    }

    @Override
    public String getProjectID() {
        return this.projectID;
    }

    @Override
    public Long getRevisionNumber() {
        return revisionNumber;
    }
{'fraction_non_alphanumeric': 0.09520123839009288, 'fraction_numerical': 0.010835913312693499, 'mean_word_length': 3.202439024390244, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3958431', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1520, 'n_words': 402}