/*
 * Copyright (C) 2004 Felipe Gustavo de Almeida
 * Copyright (C) 2010-2014 The MPDroid Project
 *
 * All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice,this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.a0z.mpd.item;

import org.a0z.mpd.Tools;

import java.util.Arrays;

public class Stream extends Item {
    private final String name;
    protected final String url;
    private int pos;

    public Stream(String name, String url, int pos) {
        this.name = name;
        this.url = url;
        this.pos = pos;
    }

    @Override
    public String getName() {
        return name;
    }
    public String getUrl() {
        return url;
    }
    public int getPos() { return pos; }
    public void setPos(int p) { pos=p; }

    /**
     * Compares an Artist object with a general contract of
     * comparison that is reflexive, symmetric and transitive.
     *
     * @param o The object to compare this instance with.
     * @return True if the objects are equal with regard to te general contract, false otherwise.
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(final Object o) {
        Boolean isEqual = null;

        if (this == o) {
            isEqual = Boolean.TRUE;
        } else if (o == null || getClass() != o.getClass()) {
            isEqual = Boolean.FALSE;
        }

        if (isEqual == null || isEqual.equals(Boolean.TRUE)) {
            final Stream stream = (Stream) o;

            if (Tools.isNotEqual(name, stream.name)) {
                isEqual = Boolean.FALSE;
            }

            if (Tools.isNotEqual(url, stream.url)) {
                isEqual = Boolean.FALSE;
            }
        }

        if (isEqual == null) {
            isEqual = Boolean.TRUE;
        }

        return isEqual.booleanValue();
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(new Object[]{name, url});
    }
}

@@ -1521,16 +1521,17 @@
  Item %7B%0A
+%0A
     priv
@@ -1551,27 +1551,27 @@
 ing 
-n
+mN
 ame;%0A
+%0A
     pr
-otected
+ivate
  fin
@@ -1580,21 +1580,23 @@
  String 
-u
+mU
 rl;%0A
+%0A
     priv
@@ -1603,17 +1603,18 @@
 ate int 
-p
+mP
 os;%0A%0A   
@@ -1628,16 +1628,22 @@
  Stream(
+final 
 String n
@@ -1646,16 +1646,22 @@
 ng name,
+ final
  String 
@@ -1664,16 +1664,22 @@
 ing url,
+ final
  int pos
@@ -1694,14 +1694,28 @@
     
-this.n
+super();%0A%0A        mN
 ame 
@@ -1734,14 +1734,10 @@
     
-this.u
+mU
 rl =
@@ -1754,14 +1754,10 @@
     
-this.p
+mP
 os =
@@ -1828,17 +1828,18 @@
  return 
-n
+mN
 ame;%0A   
@@ -1833,32 +1833,87 @@
 rn mName;%0A    %7D%0A
+%0A    public int getPos() %7B%0A        return mPos;%0A    %7D%0A%0A
     public Strin
@@ -1940,17 +1940,18 @@
  return 
-u
+mU
 rl;%0A    
@@ -1948,24 +1948,25 @@
 mUrl;%0A    %7D%0A
+%0A
     public i
@@ -1968,75 +1968,60 @@
 lic 
-int getPos() %7B return pos; %7D%0A    public void setPos(int p) %7B pos=p;
+void setPos(final int pos) %7B%0A        mPos = pos;%0A   
  %7D%0A%0A
@@ -2761,17 +2761,18 @@
 otEqual(
-n
+mN
 ame, str
@@ -2775,17 +2775,18 @@
  stream.
-n
+mN
 ame)) %7B%0A
@@ -2874,17 +2874,18 @@
 otEqual(
-u
+mU
 rl, stre
@@ -2887,17 +2887,18 @@
  stream.
-u
+mU
 rl)) %7B%0A 
@@ -3176,15 +3176,17 @@
 t%5B%5D%7B
-n
+mN
 ame, 
-u
+mU
 rl%7D)

Clean Stream item.