Java tutorial
/* * Copyright 2014 the original author or authors. * * 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.github.carlomicieli.footballdb.starter; import io.github.carlomicieli.footballdb.starter.domain.PlayerCareer; import io.github.carlomicieli.footballdb.starter.domain.PlayerProfile; import io.github.carlomicieli.footballdb.starter.domain.TeamRoster; import io.github.carlomicieli.footballdb.starter.parsers.PlayerCareerParser; import io.github.carlomicieli.footballdb.starter.parsers.PlayerProfileParser; import io.github.carlomicieli.footballdb.starter.parsers.TeamRosterParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import java.util.Optional; /** * @author Carlo Micieli */ @Component @SuppressWarnings("unused") public class Samples implements CommandLineRunner { @Autowired private TeamRosterParser teamRosters; @Autowired private PlayerProfileParser playerProfile; @Autowired private PlayerCareerParser playerCareer; @Override public void run(String... args) throws Exception { Optional<TeamRoster> roster = teamRosters.parse("/teams/sanfrancisco49ers/roster?team=SF"); roster.ifPresent(r -> r.playersStream().forEach(p -> App.log().info("> {}", p))); Optional<PlayerProfile> peytonManningProfile = playerProfile.parse("/player/peytonmanning/2501863/profile"); peytonManningProfile.ifPresent(p -> App.log().info("{}", p)); Optional<PlayerCareer> drewBreesCareer = playerCareer.parse("/player/drewbrees/2504775/profile"); drewBreesCareer.ifPresent(cr -> cr.seasonStream().forEach(s -> App.log().info("> {}", s))); } }