/*
 * Copyright 2012 Ryuji Yamashita
 *
 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
 *
 * 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 facebook4j.internal.json;

import facebook4j.FacebookException;
import facebook4j.IdName;
import facebook4j.ResponseList;
import facebook4j.conf.Configuration;
import facebook4j.internal.http.HttpResponse;
import facebook4j.internal.org.json.JSONArray;
import facebook4j.internal.org.json.JSONException;
import facebook4j.internal.org.json.JSONObject;

/**
 * @author Ryuji Yamashita - roundrop at gmail.com
 */
/*package*/ class IdNameJSONImpl extends FacebookResponseImpl implements IdName, java.io.Serializable {
    private static final long serialVersionUID = -1724969319460349501L;

    protected String id;
    protected String name;
    
    /*package*/IdNameJSONImpl(HttpResponse res, Configuration conf) throws FacebookException {
        super(res);
        JSONObject json = res.asJSONObject();
        init(json);
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
            DataObjectFactoryUtil.registerJSONObject(this, json);
        }
    }
    
    /*package*/IdNameJSONImpl(JSONObject json) throws FacebookException {
        super();
        init(json);
    }

    private void init(JSONObject json) throws FacebookException {
        try {
            id = json.getString("id");
            name = json.getString("name");
        } catch (JSONException jsone) {
            throw new FacebookException(jsone);
        }
    }
    
    public String getId() {
        return id;
    }
    public String getName() {
        return name;
    }

    /*package*/
    static ResponseList<IdName> createIdNameList(HttpResponse res, Configuration conf) throws FacebookException {
        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            int size = list.length();
            ResponseList<IdName> idNames = new ResponseListImpl<IdName>(size, json);
            for (int i = 0; i < size; i++) {
                IdName entity = new IdNameJSONImpl(list.getJSONObject(i));
                idNames.add(entity);
            }
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(idNames, json);
            }
            return idNames;
        } catch (JSONException jsone) {
            throw new FacebookException(jsone);
        }
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        IdNameJSONImpl other = (IdNameJSONImpl) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "IdNameJSONImpl [name=" + name + ", id=" + id + "]";
    }

}

@@ -716,41 +716,8 @@
 e;%0D%0A
-import facebook4j.ResponseList;%0D%0A
 impo
@@ -802,56 +802,8 @@
 e;%0D%0A
-import facebook4j.internal.org.json.JSONArray;%0D%0A
 impo
@@ -1121,28 +1121,27 @@
 D = 
--1724969319460349501
+3690969204489575083
 L;%0D%0A
@@ -2103,964 +2103,8 @@
 %0D%0A%0D%0A
-    /*package*/%0D%0A    static ResponseList%3CIdName%3E createIdNameList(HttpResponse res, Configuration conf) throws FacebookException %7B%0D%0A        try %7B%0D%0A            if (conf.isJSONStoreEnabled()) %7B%0D%0A                DataObjectFactoryUtil.clearThreadLocalMap();%0D%0A            %7D%0D%0A            JSONObject json = res.asJSONObject();%0D%0A            JSONArray list = json.getJSONArray(%22data%22);%0D%0A            int size = list.length();%0D%0A            ResponseList%3CIdName%3E idNames = new ResponseListImpl%3CIdName%3E(size, json);%0D%0A            for (int i = 0; i %3C size; i++) %7B%0D%0A                IdName entity = new IdNameJSONImpl(list.getJSONObject(i));%0D%0A                idNames.add(entity);%0D%0A            %7D%0D%0A            if (conf.isJSONStoreEnabled()) %7B%0D%0A                DataObjectFactoryUtil.registerJSONObject(idNames, json);%0D%0A            %7D%0D%0A            return idNames;%0D%0A        %7D catch (JSONException jsone) %7B%0D%0A            throw new FacebookException(jsone);%0D%0A        %7D%0D%0A    %7D%0D%0A    %0D%0A
     

Remove needless method