com.pepaproch.gtswsdlclient.impl.AvailabilityCheckByPhoneQueryBuilderImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.pepaproch.gtswsdlclient.impl.AvailabilityCheckByPhoneQueryBuilderImpl.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pepaproch.gtswsdlclient.impl;

import com.pepaproch.gtswsdl.QueryBuilder;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

/**
 *
 * @author pepa
 */
public class AvailabilityCheckByPhoneQueryBuilderImpl implements QueryBuilder<String> {

    private final String url;
    private final static String PHONE_FIELD_NAME = "phoneNumber";

    public AvailabilityCheckByPhoneQueryBuilderImpl(String url) {
        this.url = url;

    }

    @Override
    public UriComponents buildQuery(String phoneNumber) {
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
        if (phoneNumber != null) {
            builder.queryParam(PHONE_FIELD_NAME, phoneNumber);
        }

        return builder.build();
    }

}