Wednesday, 27 September 2017

How to use map methods of stream | Java 8 streams | Streams in Java 8


Click here to watch in Youtube :
https://www.youtube.com/watch?v=8Wqtd9xz7sk&list=UUhwKlOVR041tngjerWxVccw

Person.java
enum Gender
{
    MALE, FEMALE
}

public class Person
{
    private String name;
    private String email;
    private Gender gender;
    private int age;

    public Person(String name, String email, Gender gender, int age)
    {
        super();
        this.name = name;
        this.email = email;
        this.gender = gender;
        this.age = age;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    public Gender getGender()
    {
        return gender;
    }

    public void setGender(Gender gender)
    {
        this.gender = gender;
    }

    public int getAge()
    {
        return age;
    }

    public void setAge(int age)
    {
        this.age = age;
    }

    @Override
    public String toString()
    {
        return "Person [name=" + name + ", gender=" + gender + ", age=" + age
                + "]";
    }

}
StreamMapDemo.java
import java.util.ArrayList;
import java.util.List;

public class StreamMapDemo
{
    public static void main(String[] args)
    {
        List<Person> personList = new ArrayList<>();

        personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 16));
        personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 15));
        personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23));
        personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19));
        personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 26));

        /*
         * The map operation returns a new stream consisting of elements which
         * are the results of applying a given function to the elements of the
         * current stream. For example, converting a stream of Objects to a
         * stream of String or a stream of primitive numbers.
         *
         * The Stream API provides 4 methods for the map operation:
         *
         * map(): transforms a stream of objects of type T to a stream of
         * objects of type R.
         *
         * mapToInt(): transforms a stream of objects to a stream of int
         * primitives.
         *
         * mapToLong(): transforms a stream of objects to a stream of long
         * primitives.
         *
         * mapToDouble(): transforms a stream of objects to a stream of double
         * primitives.
         *
         */
        
        personList.stream()                     // Stream<Person>
                  .map(p -> p.getEmail())      //  Stream<String>
                  .forEach(System.out::println);

        System.out.println("\n----------------------\n");
        
        personList.stream()  // Stream<Person>
                  .map(p -> p.getName().toUpperCase()) //  Stream<String>
                  .forEach(System.out::println);

        System.out.println("\n----------------------\n");

        personList.stream()  // Stream<Person>
                  .mapToInt(p -> p.getAge()) //IntStream
                  .forEach(age -> System.out.println(age));

    }

}
Output
alice@gmail.com
bob@gmail.com
carol@gmail.com
david@gmail.com
eric@gmail.com

----------------------

ALICE
BOB
CAROL
DAVID
ERIC

----------------------

16
15
23
19
26

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/StreamDemo_map_person_name_age.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StreamDemo_map_person_name_age

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4c6dd26ede26896338d54f8923608ecad05bf799/BasicJava/StreamDemo_map_person_name_age/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • How to filter the List of Person based on Gender using Java 8 Stream | Streams in Java 8


    Click here to watch in Youtube : 
    https://www.youtube.com/watch?v=DQVdAQPUkuk&list=UUhwKlOVR041tngjerWxVccw

    Person.java
    enum Gender
    {
        MALE, FEMALE
    }
    
    public class Person
    {
        private String name;
        private String email;
        private Gender gender;
        private int age;
    
        public Person(String name, String email, Gender gender, int age)
        {
            super();
            this.name = name;
            this.email = email;
            this.gender = gender;
            this.age = age;
        }
    
        public String getName()
        {
            return name;
        }
    
        public void setName(String name)
        {
            this.name = name;
        }
    
        public String getEmail()
        {
            return email;
        }
    
        public void setEmail(String email)
        {
            this.email = email;
        }
    
        public Gender getGender()
        {
            return gender;
        }
    
        public void setGender(Gender gender)
        {
            this.gender = gender;
        }
    
        public int getAge()
        {
            return age;
        }
    
        public void setAge(int age)
        {
            this.age = age;
        }
    
        @Override
        public String toString()
        {
            return "Person [name=" + name + ", gender=" + gender + ", age=" + age
                    + "]";
        }
    
    }
    
    StreamFilterDemo.java
    import java.util.ArrayList;
    import java.util.List;
    
    public class StreamFilterDemo
    {
        public static void main(String[] args)
        {
            List<Person> personList = new ArrayList<>();
    
            personList.add(new Person("Alice","alice@gmail.com",Gender.FEMALE, 16));
            personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 15));
            personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23));
            personList.add(new Person("David","david@gmail.com",    Gender.MALE, 19));
            personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26));
            
            System.out.println("--------Filterd based on FEMALE--------");
            
            /*
             * The filter() operation returns a new stream that consists elements
             * matching a given condition which is typically a boolean test in form
             * of a Lambda expression.
             * 
             * The following code lists only female persons:
             */
            personList.stream().filter(p -> p.getGender().equals(Gender.FEMALE))
                                                    .forEach(System.out::println);
            
            
            System.out.println("\n--------Filterd based on Male and Age<=25--------");
            
            /*
             * The following code shows only male who are under 25:
             */
            personList.stream().filter(p -> p.getGender().equals(Gender.MALE) && p.getAge() <= 25)
                    .forEach(System.out::println);
    
        }
    
    }
    
    Output
    --------Filterd based on FEMALE--------
    Person [name=Alice, gender=FEMALE, age=16]
    Person [name=Carol, gender=FEMALE, age=23]
    
    --------Filterd based on Male and Age<=25--------
    Person [name=Bob, gender=MALE, age=15]
    Person [name=David, gender=MALE, age=19]
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/StreamDemo_filter_person_male_age.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java/tree/master/BasicJava/StreamDemo_filter_person_male_age

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/4c6dd26ede26896338d54f8923608ecad05bf799/BasicJava/StreamDemo_filter_person_male_age/?at=master

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • GroupBy using Java 8 Stream | Java 8 streams tutorial | Java 8 streams | Streams in Java 8

    public class Student
    {
        private String studentName;
        private String teacherName;
        private int level;
        private String className;
    
        public Student(String studentName, String teacherName, int level,
                String className)
        {
            super();
            this.studentName = studentName;
            this.teacherName = teacherName;
            this.level = level;
            this.className = className;
        }
    
        public String getStudentName()
        {
            return studentName;
        }
    
        public void setStudentName(String studentName)
        {
            this.studentName = studentName;
        }
    
        public String getTeacherName()
        {
            return teacherName;
        }
    
        public void setTeacherName(String teacherName)
        {
            this.teacherName = teacherName;
        }
    
        public int getLevel()
        {
            return level;
        }
    
        public void setLevel(int level)
        {
            this.level = level;
        }
    
        public String getClassName()
        {
            return className;
        }
    
        public void setClassName(String className)
        {
            this.className = className;
        }
    
        @Override
        public String toString()
        {
            return "Student [studentName=" + studentName + ", teacherName="
                    + teacherName + ", level=" + level + ", className=" + className
                    + "]";
        }
    
    }
    
    StreamGroupByDemo1.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
    
    /**
     * Group by teacher name:
     * 
     * SELECT column_name, count(column_name) 
     * FROM table 
     * GROUP BY column_name;
     * 
     * This example will show how to "group classes by a teacher's name". Here you
     * will pass the groupingBy method a function in the form of a method reference
     * extracting each teacher name to the corresponding Student which will return 1
     * key to many elements. This is similar to guava's Multimap collection which
     * allows for easy mapping of a single key to multiple values.
     *
     */
    public class StreamGroupByDemo1
    {
        public static void main(String[] args)
        {
            List<Student> studentList = getStudentList();
    
            Map<String, List<Student>> groupByTeachersMap = studentList.stream()
                    .collect(Collectors.groupingBy(Student::getTeacherName));
    
            for (Map.Entry<String, List<Student>> entry : groupByTeachersMap
                    .entrySet())
            {
                System.out.println("Teacher Name : " + entry.getKey());
    
                List<Student> list = entry.getValue();
                for (Student student : list)
                {
                    System.out.println(student);
                }
                System.out.println("-------------------------------------");
            }
    
        }
    
        private static List<Student> getStudentList()
        {
            List<Student> studentList = new ArrayList<Student>();
            studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics"));
            studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics"));
            studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java"));
            studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics"));
            studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby"));
            return studentList;
        }
    
    }
    
    Output
    Teacher Name : Mr.John
    Student [studentName=Peter, teacherName=Mr.John, level=1, className=Java Basics]
    Student [studentName=Ram, teacherName=Mr.John, level=1, className=Webservice Basics]
    Student [studentName=Juli, teacherName=Mr.John, level=2, className=Advance Java]
    -------------------------------------
    Teacher Name : Mr.Kumar
    Student [studentName=Dave, teacherName=Mr.Kumar, level=1, className=Ruby basics]
    Student [studentName=Raja, teacherName=Mr.Kumar, level=2, className=Advance Ruby]
    -------------------------------------
    
    
    StreamGroupByDemo2.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
    
    /**
     * Group by class level:
     * 
     * SELECT column_name, count(column_name) 
     * FROM table 
     * GROUP BY column_name; 
     * 
     * This example will show "show all classes by level".
     *
     */
    public class StreamGroupByDemo2
    {
        public static void main(String[] args)
        {
            List<Student> studentList = getStudentList();
    
            Map<Integer, List<Student>> groupByLevelMap = studentList.stream()
                    .collect(Collectors.groupingBy(Student::getLevel));
    
            for (Map.Entry<Integer, List<Student>> entry : groupByLevelMap
                    .entrySet())
            {
                System.out.println("Level : " + entry.getKey());
    
                List<Student> list = entry.getValue();
                for (Student student : list)
                {
                    System.out.println(student);
                }
                System.out.println("----------------------------------");
            }
    
        }
    
        private static List<Student> getStudentList()
        {
            List<Student> studentList = new ArrayList<Student>();
            studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics"));
            studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics"));
            studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java"));
            studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics"));
            studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby"));
            return studentList;
        }
    
    }
    
    Output
    Level : 1
    Student [studentName=Peter, teacherName=Mr.John, level=1, className=Java Basics]
    Student [studentName=Ram, teacherName=Mr.John, level=1, className=Webservice Basics]
    Student [studentName=Dave, teacherName=Mr.Kumar, level=1, className=Ruby basics]
    ----------------------------------
    Level : 2
    Student [studentName=Juli, teacherName=Mr.John, level=2, className=Advance Java]
    Student [studentName=Raja, teacherName=Mr.Kumar, level=2, className=Advance Ruby]
    ----------------------------------
    
    
    StreamGroupByDemo3.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
    
    /**
     * GroupBy aggregate:
     * 
     * SELECT LEVEL, count(LEVEL) 
     * FROM STUDENT 
     * GROUP BY LEVEL;
     * 
     * This example will "count the number of classes per level":
     * 
     */
    public class StreamGroupByDemo3
    {
        public static void main(String[] args)
        {
            List<Student> studentList = getStudentList();
    
            /*
             * In an overloaded groupingBy method, you can pass a second collector.
             * Collectors have various reduce operations which can be passed, in
             * this case Collectors.counting which will count the number of classes
             * in each level.
             */
            Map<Integer, Long> groupByLevelMap = studentList.stream()
                    .collect(Collectors.groupingBy(Student::getLevel,Collectors.counting()));
    
            for (Map.Entry<Integer, Long> entry : groupByLevelMap.entrySet())
            {
                System.out.println("Level = " + entry.getKey() + ", Count = "
                        + entry.getValue());
            }
    
        }
    
        private static List<Student> getStudentList()
        {
            List<Student> studentList = new ArrayList<Student>();
            studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics"));
            studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics"));
            studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java"));
            studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics"));
            studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby"));
            return studentList;
        }
    
    }
    
    Output
    Level = 1, Count = 3
    Level = 2, Count = 2
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/StreamDemo_groupBy_level.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java/tree/master/BasicJava/StreamDemo_groupBy_level

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/4c6dd26ede26896338d54f8923608ecad05bf799/BasicJava/StreamDemo_groupBy_level/?at=master

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • What are the core stream operations of Java 8 Stream V2| Streams in Java


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=zTtAKC0sbSg&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    What are the core stream operations of Java 8 Stream V2| Streams in Java
    What are the core stream operations of Java 8 Stream V2| Streams in Java
    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Tuesday, 26 September 2017

    What is Stream V2 | Java 8 streams tutorial | Java 8 streams | Streams in Java 8


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=DQVdAQPUkuk&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    What is Stream V2 | Java 8 streams tutorial | Java 8 streams | Streams in Java 8
    StreamDemo.java
    import java.util.Arrays;
    import java.util.Collection;
    
    public class StreamDemo
    {
        public static void main(String[] args)
        {
            Collection<String> nameList = Arrays.asList("Peter", "John", "Ram");
    
            /*
             * Following code prints strings greater than length 5 by iterating a
             * collection.
             */
            nameList.stream().filter(name -> name.length() > 3)
                    .forEach(name -> System.out.println(name));
        }
    
    }
    
    Output
    Peter
    John
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/StreamDemo_SIT.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java/tree/master/BasicJava/StreamDemo_SIT

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/5eb462211ac2fd9fb1bace2049e170a49c5caa69/BasicJava/StreamDemo_SIT/?at=master

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Grouping using Java 8 Streams without any loops | Java 8 streams | Streams in Java 8


    Click here to watch in Youtube : 
    https://www.youtube.com/watch?v=FhXkXaroVKc&list=UUhwKlOVR041tngjerWxVccw

    Article.java
    public class Article
    {
        private String title;
        private String author;
        private String tagName;
    
        public Article(String title, String author, String tagName)
        {
            super();
            this.title = title;
            this.author = author;
            this.tagName = tagName;
        }
    
        public String getTitle()
        {
            return title;
        }
    
        public void setTitle(String title)
        {
            this.title = title;
        }
    
        public String getAuthor()
        {
            return author;
        }
    
        public void setAuthor(String author)
        {
            this.author = author;
        }
    
        public String getTagName()
        {
            return tagName;
        }
    
        public void setTagName(String tagName)
        {
            this.tagName = tagName;
        }
    
        @Override
        public String toString()
        {
            return "Article [title=" + title + ", author=" + author + ", tagName="
                    + tagName + "]";
        }
    
    }
    
    StreamDemo1.java
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
    
    /**
     * Group all the articles based on the author.
     */
    public class StreamDemo1
    {
        public static void main(String[] args)
        {
            List<Article> articleList = getArticleList();
    
            Map<String, List<Article>> groupByAuthorMap = groupByAuthorUsingForLoop(
                    articleList);
    
            for (String key : groupByAuthorMap.keySet())
            {
                System.out.println(key + " = " + groupByAuthorMap.get(key));
            }
    
            System.out.println("-----------------------------");
    
            groupByAuthorMap = groupByAuthorUsingStream(articleList);
            for (String key : groupByAuthorMap.keySet())
            {
                System.out.println(key + " = " + groupByAuthorMap.get(key));
            }
        }
    
        private static Map<String, List<Article>> groupByAuthorUsingForLoop(
                List<Article> articleList)
        {
            /*
             * Before JDK8 - Using a for-loop
             */
            Map<String, List<Article>> groupByAuthorMap = new HashMap<>();
    
            for (Article article : articleList)
            {
                if (groupByAuthorMap.containsKey(article.getAuthor()))
                {
                    groupByAuthorMap.get(article.getAuthor()).add(article);
                }
                else
                {
                    ArrayList<Article> articles = new ArrayList<>();
                    articles.add(article);
                    groupByAuthorMap.put(article.getAuthor(), articles);
                }
            }
    
            return groupByAuthorMap;
        }
    
        private static Map<String, List<Article>> groupByAuthorUsingStream(
                List<Article> articleList)
        {
            /*
             * With JDK 8 - Using operations from the stream API
             */
            Map<String, List<Article>> groupByAuthorMap = articleList
                    .stream()
                    .collect(Collectors.groupingBy(Article::getAuthor));
            return groupByAuthorMap;
        }
        
    
        private static List<Article> getArticleList()
        {
            List<Article>  listOfArticle = new ArrayList<Article>();
            
            listOfArticle.add(new Article("Java complete Reference","John","Java"));
            listOfArticle.add( new Article("Java Programming","John","Java"));
            listOfArticle.add(new Article("RESTful web services","Peter","Web Service"));       
            listOfArticle.add(new Article("Programming Ruby","Peter","Ruby"));
            
            return listOfArticle;       
        }
    }
    
    Output
    John = [Article [title=Java complete Reference, author=John, tagName=Java], 
            Article [title=Java Programming, author=John, tagName=Java]]
    Peter = [Article [title=RESTful web services, author=Peter, tagName=Web Service], 
            Article [title=Programming Ruby, author=Peter, tagName=Ruby]]
    -----------------------------
    John = [Article [title=Java complete Reference, author=John, tagName=Java], 
           Article [title=Java Programming, author=John, tagName=Java]]
    Peter = [Article [title=RESTful web services, author=Peter, tagName=Web Service], 
            Article [title=Programming Ruby, author=Peter, tagName=Ruby]]
    
    
    StreamDemo2.java
    import java.util.ArrayList;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;
    import java.util.stream.Collectors;
    
    /**
     * Get DistinctTagNames in the collection.
     */
    public class StreamDemo2
    {
        public static void main(String[] args)
        {
            List<Article> articleList = getArticleList();
            Set<String> distinctTagNamesSet = getDistinctTagNamesUsingForLoop(articleList);     
            System.out.println(distinctTagNamesSet);
            
            System.out.println("------------------------------------------------------------------");
            
            distinctTagNamesSet = getDistinctTagNamesUsingStream(articleList);      
            System.out.println(distinctTagNamesSet);
        }
        
        
        private static Set<String> getDistinctTagNamesUsingForLoop(List<Article> articleList)
        {
            /*
             * Before JDK8 - Using a for-loop
             */
            Set<String> distinctTagNamesSet = new HashSet<>();
    
            for (Article article : articleList)
            {
                distinctTagNamesSet.add(article.getTagName());
            }
    
            return distinctTagNamesSet;
        }
    
        private static Set<String> getDistinctTagNamesUsingStream(List<Article> articleList)
        {
            /*
             * With JDK 8 - Using operations from the stream API
             */
            Set<String> distinctTagNamesSet = articleList.stream()
                    .map(article -> article.getTagName()).distinct()
                    .collect(Collectors.toSet());
    
            return distinctTagNamesSet;
    
        }
        
    
        private static List<Article> getArticleList()
        {
            List<Article>  listOfArticle = new ArrayList<Article>();
            
            listOfArticle.add(new Article("Java complete Reference","John","Java"));
            listOfArticle.add( new Article("Java Programming","John","Java"));
            listOfArticle.add(new Article("RESTful web services","John","Web Service"));        
            listOfArticle.add(new Article("Programming Ruby","John","Ruby"));
            
            return listOfArticle;       
        }
    
    }
    
    Output
    [Java, Ruby, Web Service]
    ------------------------------------------------------------------
    [Java, Ruby, Web Service]
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/StreamDemo_2_no_loop_Article_group.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java/tree/master/BasicJava/StreamDemo_2_no_loop_Article_group

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/5eb462211ac2fd9fb1bace2049e170a49c5caa69/BasicJava/StreamDemo_2_no_loop_Article_group/?at=master

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial