/*
 * Copyright 2015 Michael Rozumyanskiy
 *
 * 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 io.michaelrocks.lightsaber.processor.annotations;

import org.apache.commons.lang3.Validate;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@ParametersAreNonnullByDefault
class AnnotationArrayParser extends AbstractAnnotationParser {
    private final List<Object> values = new ArrayList<>();

    public List<Object> getValues() {
        return Collections.unmodifiableList(values);
    }

    @Override
    protected void addValue(final String name, final Object value) {
    protected void addValue(@Nullable final String name, final Object value) {
        Validate.isTrue(name == null);
        values.add(value);
    }
}

@@ -965,16 +965,30 @@
 arser %7B%0A
+    @Nullable%0A
     priv
@@ -991,22 +991,16 @@
 private 
-final 
 List%3CObj
@@ -1014,28 +1014,8 @@
 lues
- = new ArrayList%3C%3E()
 ;%0A%0A 
@@ -1065,16 +1065,59 @@
   return
+ values == null ? Collections.emptyList() :
  Collect
@@ -1196,16 +1196,26 @@
 ddValue(
+@Nullable 
 final St
@@ -1255,79 +1255,69 @@
     
-protected void addValue(@Nullable final String name, final Object value
+    Validate.isTrue(name == null);%0A        if (values == null
 ) %7B%0A
@@ -1328,38 +1328,49 @@
     
+  
-Validate.isTrue(name == null);
+  values = new ArrayList%3C%3E();%0A        %7D
 %0A   

Create a list lazily in AnnotationArrayParser